Click here to Skip to main content
15,885,757 members
Home / Discussions / C#
   

C#

 
GeneralRe: A similar action to a try catch statement? Pin
Kuira10-Nov-05 13:25
Kuira10-Nov-05 13:25 
GeneralRe: A similar action to a try catch statement? Pin
Christian Graus10-Nov-05 13:27
protectorChristian Graus10-Nov-05 13:27 
GeneralRe: A similar action to a try catch statement? Pin
Kuira10-Nov-05 13:46
Kuira10-Nov-05 13:46 
GeneralRe: A similar action to a try catch statement? Pin
Leslie Sanford10-Nov-05 18:47
Leslie Sanford10-Nov-05 18:47 
GeneralRe: A similar action to a try catch statement? Pin
Kuira13-Nov-05 12:15
Kuira13-Nov-05 12:15 
GeneralRe: A similar action to a try catch statement? Pin
Leslie Sanford13-Nov-05 13:11
Leslie Sanford13-Nov-05 13:11 
GeneralRe: A similar action to a try catch statement? Pin
Kuira13-Nov-05 17:05
Kuira13-Nov-05 17:05 
GeneralRe: A similar action to a try catch statement? Pin
Leslie Sanford13-Nov-05 17:37
Leslie Sanford13-Nov-05 17:37 
Kuira wrote:
Ok, from the exception part, if Test1 fails from there, will that means that Test2 wont fire from the algorithm you written up?


Right. Say you did something like this, building on the code example I provided in the previous post:

public void SomeMethod()
{
    try
    {
        Test();
    }
    catch(TestException ex)
    {
        // Notify user that a failure occurred (if we're using a form,
        // we might display a message box instead).
        Console.WriteLine(ex.Message);
    }
}


When an exception gets thrown from one of Test methods, flow of control jumps immediately to the catch block above without executing any of later Test methods.

Kuira wrote:
I'll just make a simple exception thats derived or something to say true or false, as long as I dont need to use if statements whenever I need to check each methods return value.


You can include an error message with the exception. Since each Test method knows what its purpose is, by having them throw an exception upon failure, they know also know what the error message should be (see my example in the previous post).
GeneralRe: A similar action to a try catch statement? Pin
Kuira14-Nov-05 11:53
Kuira14-Nov-05 11:53 
QuestionParsing an XML string Pin
Ravi Bhavnani10-Nov-05 11:49
professionalRavi Bhavnani10-Nov-05 11:49 
AnswerRe: Parsing an XML string Pin
Ravi Bhavnani10-Nov-05 12:09
professionalRavi Bhavnani10-Nov-05 12:09 
Question.net 2.0 Membership in Windows Applications? Pin
MightyJoe10-Nov-05 11:11
MightyJoe10-Nov-05 11:11 
QuestionDrag Drop within a Control Pin
miah alom10-Nov-05 10:41
miah alom10-Nov-05 10:41 
QuestionByValue parameter is not used Pin
Seraphin10-Nov-05 10:08
Seraphin10-Nov-05 10:08 
AnswerRe: ByValue parameter is not used Pin
Leslie Sanford10-Nov-05 11:02
Leslie Sanford10-Nov-05 11:02 
GeneralRe: ByValue parameter is not used Pin
Seraphin10-Nov-05 13:14
Seraphin10-Nov-05 13:14 
GeneralRe: ByValue parameter is not used Pin
Leslie Sanford10-Nov-05 16:44
Leslie Sanford10-Nov-05 16:44 
QuestionOkay, i gotta question - who wants to look? Pin
Anthony Mushrow10-Nov-05 9:54
professionalAnthony Mushrow10-Nov-05 9:54 
AnswerRe: Okay, i gotta question - who wants to look? Pin
Christian Graus10-Nov-05 13:35
protectorChristian Graus10-Nov-05 13:35 
QuestionPackage load error in VS2005? Pin
TheGreatAndPowerfulOz10-Nov-05 8:38
TheGreatAndPowerfulOz10-Nov-05 8:38 
QuestionLabel question Pin
Stanciu Vlad10-Nov-05 7:52
Stanciu Vlad10-Nov-05 7:52 
AnswerRe: Label question Pin
Anthony Mushrow10-Nov-05 8:01
professionalAnthony Mushrow10-Nov-05 8:01 
GeneralRe: Label question Pin
Stanciu Vlad10-Nov-05 8:35
Stanciu Vlad10-Nov-05 8:35 
AnswerRe: Label question Pin
Stanciu Vlad10-Nov-05 9:08
Stanciu Vlad10-Nov-05 9:08 
GeneralRe: Label question Pin
Anthony Mushrow10-Nov-05 9:27
professionalAnthony Mushrow10-Nov-05 9:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.