I am pretty new to C#, but I do have some experience with programming ("some" being the operative word here). I am wondering what is the best way to completely exit out of code at a certain time.
For example, I am writing an application to read in a Photoshop file, measure all the slices, then generate some HTML based on that information.
Right now, I have a class (PSDFile) that performs the necessary operations to read the PSD file and gather the slice information. This information is held in another class (Slices). Once that data is gathered, it is passed into another class (HTMLGen) that performs the necessary operations to turn the Slice information into HTML.
The problem I'm running into is when I'm checking each stage for errors. In the PSDFile class, I check to make sure that the file exists first. If not, I need to alert the user via message box and stop the process. If so, I proceed to the next step, measuring the slices. If there is an error with the slices, I need to again alert the user via message box and stop the process. There are other places in the code where I need to check for certain things and stop if the criteria is not right.
What is the best way to go about doing this? Right now I could do a bunch of if/then statements with "return", but as the application gets large (I plan on adding a lot more features to this), I think doing it that way would be bad.
Can anyone point me in the right direction? Hope this makes sense.