输入email 按照@分割成两个部分 但是输入第一个结果不显示,第二个正确,为什么?
            string str1 = textBox1.Text;
            string str2 = textBox2.Text;
            string str3 = textBox3.Text;            string[] a =  str1.Split('@');
            if (a.Length != 2)
            {
                MessageBox.Show("天大的错误");
                return;
            }
            str2 = a[0];
            str3 = a[1];
             string str1 = textBox1.Text;
             string[] a =  str1.Split('@');            if (a.Length != 2)
            {
                MessageBox.Show("天大的错误");
                return;
            }
            textBox2.Text = a[0];
            textBox3.Text = a[1];
            

解决方案 »

  1.   

    第1个你是把值给str2 和str3 了没给textBox2,textBox3
      

  2.   

    你输入的值是多少?
    void Main()
    {
    string s="[email protected]";
    Console.WriteLine(s.Split('@')[0]);
    Console.WriteLine(s.Split('@')[1]);
    }/*
    aaa
    bb.om*/
      

  3.   


       string email = "[email protected]";
                string[] a = email.Split('@');
                string str1=null;
                string str2=null;
                foreach (string item in a)
                {
                     str1 = a[0];
                     str2 = a[1];
                }
                Console.WriteLine(str1);            Console.WriteLine(str2);
      

  4.   

    string str1 = textBox1.Text;
      string str2 = textBox2.Text;
      string str3 = textBox3.Text;  string[] a = str1.Split('@');
      if (a.Length != 2)
      {
      MessageBox.Show("天大的错误");
      return;
      }
      str2 = a[0];
      str3 = a[1];textBox2.Text = str2;
    textBox3.Text = str3;就行了
      

  5.   

    输入一个普通的邮箱 eg. [email protected]
    结果应该是 labiying    163.com
    但是,第一个不显示结果