判断一个数值是否在一个逗号分隔的字符串中


  1. 使用表达式方式:
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
  }
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM