c# - locking a case after action? is this possible? -


let's have code this:

switch ( value ) {  case 1 "hello" // <--- whatever word in here command make following happen:  name.systemtext("good job!"); // display in console  case 2 "hi" name.systemtext("a job also!");  case 3 "bye" name.systemtext("many great jobs had"); 

i want prevent these repeatable.

so if @ case 2, don't want user able repeat hello or hi once action "good job" has been displayed. instead i'd want display message input has been typed , force person go case left, 3 ("bye").

i tried make clear possible hope can help. i'm going guess tell me achieve i'll need use other switch? i'm fine i'm curious whether possible.

how this:

private list<string> _possiblecases = new list<string>{"hello", "hi", ...}; ...  var valuetocheck = "hi"; var foundcase = this._possiblecases.firstordefault(x => x == valuetocheck);  if (foundcase != null) this._possiblecases.remove(foundcase);  switch (foundcase) {     case "hello":         // ...         break;     case "hi":         // ...         break;     ...     default:         // ...         break; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -