indexof
判断的时候找"5,"以及最后一个字符是否为",5"。
只有这两种情况才算包含。

解决方案 »

  1.   

    意思可能理解错了,我是说 b 也许会是 string b="1,2,3,4,6565,6,7";
    这样 用 b.indexof  不行哦。。
      

  2.   

    我就是想用 字符串数组 来做,,代码如何,因为 a   b 都是 ID 字段,我想看是否包含
      

  3.   

    什莫意思?那你用split把b按照“,”拆分成数组,再和a比较吧!
      

  4.   

    string [] astr = b.split(",")
    if( a in astr )
    //伪码
      

  5.   

    char ch = ',';
    String [] myArray = b.Split(ch);
    int nPos = myArray.IndexOf(a)
      

  6.   

    Array myArray=Array.CreateInstance( typeof(String), 12 );
          myArray.SetValue( "the", 0 );
          myArray.SetValue( "quick", 1 );
          myArray.SetValue( "brown", 2 );
          myArray.SetValue( "fox", 3 );
          myArray.SetValue( "jumps", 4 );
          myArray.SetValue( "over", 5 );
          myArray.SetValue( "the", 6 );
          myArray.SetValue( "lazy", 7 );
          myArray.SetValue( "dog", 8 );
          myArray.SetValue( "in", 9 );
          myArray.SetValue( "the", 10 );
          myArray.SetValue( "barn", 11 );      // Searches for the first occurrence of the duplicated value.
          String myString = "the";
          int myIndex = Array.IndexOf( myArray, myString );
      

  7.   

    string ChildIdItems=mytree2.GetCheckItems(mytreeview.Nodes,id.Text);//当前编辑节点ID的所有子ID,包括自己ID
    Response.Write(ChildIdItems+"<br>");
    // Response.Write(ChildIdItems.array(CurrentId);
    string[] MyChildIdItems=ChildIdItems.Split(","); Response.Write(MyChildIdItems); if (CurrentId in MyChildIdItems )
    {if (CurrentId in MyChildIdItems ) 这句有问题吗????
      

  8.   

    char ch = ',';
    String [] myArray = b.Split(ch);
    int nPos = myArray.IndexOf(a)
    系统说 myArray 都没有 IndexOf 方法,,,晕了。
      

  9.   

    string a="5";
    string c="545";string b="1,2,3,4,545,6,7";其实我的意思很简单,只要判断出 b 包含 c  ,    b 不包含 a 
    就可以了,也就是 把 545  当成一个整体元素来看待,不算太复杂把,,但是char ch = ',';
    String [] myArray = b.Split(ch);
    int nPos = myArray.IndexOf(a)居然不行说没有 IndexOf 方法??????????????????????????????????????????好晕啊。。