- 使用表达式方式:
string s = "12,123,1234,32,321,345";
if (s.Split(‘,‘).Any(x => x == "12"))
//存在
2.
string a = "1,2,3,4,5,6";
if(a.IndexOf(“3,")>-1)
{
//字符串A中包含字符串B
}
string a = "1,2,3,4,5,6";
List<string> oTempList = new List<string>(a.Split(‘,‘}));
if(oTempList.Contains(“3"))
{
//字符串数据A中包含字符串元素B
}
时间: 2024-12-05 23:30:17