How to use string.Endswith to test for multiple endings?

前端 未结 9 2465
死守一世寂寞
死守一世寂寞 2020-12-08 21:17

I need to check in string.Endswith(\"\") from any of the following operators: +,-,*,/

If I have 20 operators I don\'t want to use ||<

9条回答
  •  感情败类
    2020-12-08 21:39

    Given the complete lack of context, would this solution that is worse than using an easy || operator be of use:

    Boolean check = false;
    if (myString.EndsWith("+"))
         check = true;
    
    if (!check && myString.EndsWith("-"))
         check = true;
    
    if (!check && myString.EndsWith("/"))
         check = true;
    
    etc.
    

提交回复
热议问题