c# - Switch Case Causing Trouble In Going To A particular Function -


     funwithscheduling fun = new funwithscheduling();      console.writeline("this scheduler");      console.writeline("what wish do");      console.writeline("enter 1 add, 2 edit, 3 search , 4 exit");      int choice = convert.toint32(console.readline());      switch (choice)      {               case 1:                   goto fun.add();                   break;               case 2:                   goto fun.edit();                   break;               case 3:                   goto fun.search();                   break;               case 4:                   goto fun.exit();                   break;              default:                    console.writeline("enter valid number");                       return;       }  } 

i got 4 functions me following add edit search exit

i want use switch case go function. possible? asked object reference , label.

why don't call method without goto ? , me it's not proper way use goto, cfr msdn reference

this should ok me :

funwithscheduling fun = new funwithscheduling();  console.writeline("this scheduler");  console.writeline("what wish do");  console.writeline("enter 1 add, 2 edit, 3 search , 4 exit");  int choice = convert.toint32(console.readline());  switch (choice)  {           case 1:               fun.add();               break;           case 2:               fun.edit();               break;           case 3:               fun.search();               break;           case 4:               fun.exit();               break;          default:                console.writeline("enter valid number");                   return;   } 

}


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -