Click here to Skip to main content
15,892,269 members
Home / Discussions / C#
   

C#

 
Questionrecording sound stream Pin
Naveed Kamboh12-May-06 5:17
Naveed Kamboh12-May-06 5:17 
QuestionHow to add Virtual Printer (vs 2003) Pin
Rizwan Bashir12-May-06 5:05
Rizwan Bashir12-May-06 5:05 
Questioncombining subexpressions into 1 Regex expression Pin
theFrenchHornet12-May-06 5:04
theFrenchHornet12-May-06 5:04 
Questiona question about contextmenustrip ? Pin
cmpeng3412-May-06 4:56
cmpeng3412-May-06 4:56 
AnswerRe: a question about contextmenustrip ? Pin
NaNg1524112-May-06 5:35
NaNg1524112-May-06 5:35 
QuestionHow to Exit Nested Methods Pin
#coder0512-May-06 4:53
#coder0512-May-06 4:53 
AnswerRe: How to Exit Nested Methods Pin
DigitalKing12-May-06 5:22
DigitalKing12-May-06 5:22 
AnswerRe: How to Exit Nested Methods Pin
RicoH12-May-06 5:28
RicoH12-May-06 5:28 
You could use a return code instead of using 'void' everywhere.
The return code would indicate if the method succeeded...
Your code would become:
void event1(...) {
  //this event is called first
  if (method1())
  {
    //more stuff
  }
}

public bool method1() {
  //some stuff
  if (method2())
  {
    //more stuff
    return true;
  }
  return false;
}

public bool method2() {
  //some stuff
  if (method3())
  {
    //more stuff
    return true;
  }
  return false;
}

public bool method3() {
  //some stuff
  if (x == 0) {
    //now exit
    return false;
  }
  //more stuff
  return true;
}
another way would be to use exceptions which would make your code look like:
void event1(...) {
  try {
    //this event is called first
    method1();
    //more stuff
  }
  catch (Exception e) {
     // something went wrong...     
  }
}

public void method1() {
  //some stuff
  method2();
  //more stuff
}

public void method2() {
  //some stuff
  method3();
  //more stuff
}

public void method3() {
  //some stuff
  if (x == 0) {
    //now exit
    // create an exception
    Exception e;
    // blablabla...
    throw e;
  }
  //more stuff
}
Hope this helps...

RicoH

Don't think you are, know you are...
custom hardware & software - olloc.be
QuestionDirectX.Capture vs MVR 1000sx Pin
zoooooooooooooooooz12-May-06 4:52
zoooooooooooooooooz12-May-06 4:52 
AnswerRe: DirectX.Capture vs MVR 1000sx Pin
Dave Kreskowiak12-May-06 6:20
mveDave Kreskowiak12-May-06 6:20 
QuestionDateTime to excel date integer Pin
spin vector12-May-06 4:46
spin vector12-May-06 4:46 
AnswerRe: DateTime to excel date integer Pin
Guffa12-May-06 4:50
Guffa12-May-06 4:50 
GeneralRe: DateTime to excel date integer Pin
spin vector12-May-06 4:56
spin vector12-May-06 4:56 
QuestionControl Collection - Tabs Pin
JohnnyBoyWonder12-May-06 3:34
JohnnyBoyWonder12-May-06 3:34 
AnswerRe: Control Collection - Tabs Pin
NaNg1524112-May-06 3:48
NaNg1524112-May-06 3:48 
Questionlooking for good training material Pin
JonEngle12-May-06 3:06
JonEngle12-May-06 3:06 
AnswerRe: looking for good training material Pin
NaNg1524112-May-06 3:20
NaNg1524112-May-06 3:20 
QuestionWMI + Memory leak Pin
g00fyman12-May-06 3:00
g00fyman12-May-06 3:00 
QuestionProblems with using controls Pin
martinz081512-May-06 2:49
martinz081512-May-06 2:49 
Questionbroswer compatibility problem Pin
Parvathivadde12-May-06 2:09
Parvathivadde12-May-06 2:09 
AnswerRe: broswer compatibility problem Pin
NaNg1524112-May-06 2:14
NaNg1524112-May-06 2:14 
GeneralRe: broswer compatibility problem Pin
Parvathivadde12-May-06 2:24
Parvathivadde12-May-06 2:24 
GeneralRe: broswer compatibility problem Pin
NaNg1524112-May-06 3:09
NaNg1524112-May-06 3:09 
GeneralRe: broswer compatibility problem Pin
Parvathivadde12-May-06 3:15
Parvathivadde12-May-06 3:15 
QuestionNeed help in explicit convertion of char[] to string Pin
Ashraj198212-May-06 2:05
Ashraj198212-May-06 2:05 

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.