Alternative to if, else if

后端 未结 8 1052
后悔当初
后悔当初 2021-02-07 11:20

I have a lot of if, else if statements and I know there has to be a better way to do this but even after searching stackoverflow I\'m unsure of how to do so in my particular cas

8条回答
  •  余生分开走
    2021-02-07 11:52

    you can use dictionary.

    Dictionary textValue = new Dictionary();
    foreach (KeyValuePair textKey in textValue)
    {
      if(txtvar.BillText.IndexOf(textKey.Key) > -1) 
       return textKey.Value;
    
    }
    

提交回复
热议问题