visual studio 2010 - Switch Case Statement in C# -
i need speech recognition program i'm working on in c#.
this refers the switch statement. if have example this:
//first case statement case "open chrome": system.diagnostics.process.start(@"c:\program files\google\chrome\application\chrome.exe"); jarvis.speak("loading"); break; //second case statement case "thanks": jarvis.speak("no problem"); break;
how make if first case statement not said second 1 not work. if first case statement said allow second 1 work.
i'm thinking here need if statement i'm not sure.
thanks.
you didn't specify this, way set up, switch 1 have hit 1 time every time want switch 2 fire:
bool isvalid = false; switch(whateveryourvariableiscalled) { //first case statement case "open chrome": system.diagnostics.process.start(@"c:\program files\google\chrome\application\chrome.exe"); jarvis.speak("loading"); isvalid = true; break; //second case statement case "thanks": if (isvalid) { jarvis.speak("no problem"); } isvalid = false; break; }
Comments
Post a Comment