I need to check in string.Endswith("") from any of the following operators: +,-,*,/
string.Endswith("")
+,-,*,/
If I have 20 operators I don't want to use || operator 19 times.
||
If you are using .NET 3.5 (and above) then it is quite easy with LINQ:
string test = "foo+"; string[] operators = { "+", "-", "*", "/" }; bool result = operators.Any(x => test.EndsWith(x));
1.4m articles
1.4m replys
5 comments
57.0k users