string.EndsWith() [英] string.EndsWith()
本文介绍了string.EndsWith()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从以下任何运营商在string.Endswith():检查+, - ,*,/
I need to check in string.Endswith("") from any of the following operators: "+,-,*,/"
如果我有20个运营商我不希望使用|| 。运营商的19倍。
If I have 20 operators I don't want to use "||" operator 19 times.
推荐答案
如果您使用的是.NET 3.5,然后它是很容易使用LINQ:
If you are using .NET 3.5 then it is quite easy with LINQ:
string test = "foo+";
string[] operators = { "+", "-", "*", "/" };
bool result = operators.Any(x => test.EndsWith(x));
这篇关于string.EndsWith()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文