"1515/155646"我想找出这个"/"是出现在字符串里第几个位置上然后截取"/"前的数字  和"/"后的数字

解决方案 »

  1.   

    这个很好实现!
      用Split()可以进行分割操作!
      

  2.   

    非常基础的问题,还是自己查msdn吧!查查string类的方法
      

  3.   

    第一个用indexof
    第二个用split
      

  4.   


                string str = "1515/155646";            Console.WriteLine(str.IndexOf('/'));            var s = str.Split('/');
                Console.WriteLine(s[0]);
                Console.WriteLine(s[1]);
      

  5.   

      string str="1515/155646";
            int i=str.IndexOf('/');
                   string str1 = str.Substring(0, i);
            string str2 = str.Substring(i+1);
      

  6.   

     string msg = textBox1.Text;
                int index = msg.IndexOf('/');///获取其索引
                MessageBox.Show(index.ToString(),"提示");///分割操作;
                string[] str = msg.Split(new char[] {'/' }, StringSplitOptions.RemoveEmptyEntries);
                string output="";
                for (int i = 0; i < str.Length;i++ )
                {
                    output=output+str[i];
                   
                }
                MessageBox.Show(output);
            }你可以改进下!
      

  7.   

                string temp = "1515/155646";
                string[] tempList = temp.Split('/');
                temp = string.Empty;            for (int i = 0; i < tempList.Length; i++)
                {
                    temp = temp + tempList[i];
                }
      

  8.   

    string str="1515/155646"我想找出这个"/"是出现在字符串里第几个位置上
    int num=str.IndexOf(@"/");
    然后截取"/"前的数字 和"/"后的数字
    string /前面的字符串=str.substring(0,num);
    string /后面的字符串=str.substring(num,str.length);
      

  9.   

    Split()方法不错的  很简单