比如string str="1,21,32,44,55"

如果直接判断是否包含字符串+逗号的话,比如“1,”就会有问题,有两种方法

if (strt.StartsWith(name+",")||
    strt.Contains(","+name+",")||
    str.EndsWith(","+name))
{

}
////////////////////////方式1//////////////////////////////
String[] listValues = strSplit(',');
if (listValues.Contains(name))
{

}
////////////////////////方式2////////////////////////////////

 

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2021-07-25
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
相关资源
相似解决方案