本人刚刚重新安装了VS2005,完成之后,导入之前做过的网站,一些函数需要手动去添加引用,怎么样才能自动包含所有引用,懂得函数就可以直接用,不需要提示未定义。 另:请教个问题  string str= 1|2|3|4|5 ;
  string str1=11|22|33;
  我想求出str和str1中 以|为分割符,分割数字的个数.  如:str中存在数字的个数为:5个
     str1中则为3个。
  怎么实现?请各位说的详细些,谢谢。

解决方案 »

  1.   

    string str= "1|2|3|4|5";string[] arr = str.Split('|');arr.Length 就是你要求的
      

  2.   

    第一个问题不明白
    第二个问题
    string str = "1|2|3|4|5";
    var c = str.Split('|').Count().ToString();
      

  3.   

    str.Split('|').Length;这个是好点,呵呵
      

  4.   

    string str1 = "1|2|3|4|5";
                string[] s = str1.Split('|');
                Response.Write(s.Length.ToString());
      

  5.   

    重新安装了VS2005,有些引用文件,没有自动引用,需要手动去添加.
    比如:System.Xml,System.Xml.Linq等
    我现在要用Integer.parseInt()就提示我未定义Integer。
    怎么办?
      

  6.   

    关键是那么多DLL文件,我不知道应该添加哪一个啊。
      

  7.   

    string str= "1|2|3|4|5";string[] arr = str.Split('|');arr.Length 你所要的数字数量
      

  8.   

    我现在要用Integer.parseInt()就提示我未定义Integer。Integer这个是核心库的,不可能没引用,倒是可能system命名空间没有加,这个要看你的代码是怎么回事了
      

  9.   

    这个问题有好多种办法可解决。看你是什么目的了。想节省内存还是想节省cpu。用分割string数组相对来讲比较耗内存。
      

  10.   


    我弄懵了,Integer是vb.net的,你的到底是c#还是vb.net?
      

  11.   

     当然是C#了,那该用什么转换成int。
      

  12.   

    string str= "1|2|3|4|5";string[] arr = str.Split('|');元素个数=arr.Length
      

  13.   

    打开动态帮助,点一下不识别的类,看帮助就知道该添加哪个引用了(如果是.net的类)
      

  14.   


    你看看 这个 符不符合 你的要求(该用什么转换成int)            string str = "1 | 2 | 3 | 4 | 5";
                string[] arr = str.Split('|');
                string tr1 = arr[0]; 
                int int0 = int.Parse(tr1);