将接收到的数据字符串水平复制到1d char数组中的c#形式

因此,我只是学习C#并尝试使用数组,我通过表单应用程序从用户那里获取输入,并希望将其复制到数组中,格式如下

接收数据(字符串):

string1: "hello"
string2: "123"
       //counting how many lines and using that to determine position associated with each 
       recieved 
      char[] prevPos;
      prevPos = textBox_ReceievedData.Text.ToCharArray();

      //count how many lines of receieved data in textbox
        for (int i = 0; i < textBox_ReceievedData.Lines.Length; i++)
        {

            System.Console.WriteLine("charArray "  +prevPos[i]);
        }

现在,如果我想打电话给我,我会得到:

        prevPos[1]=h
        prevPos[2]=e 
        prevPos[3]=l
       etc.

但我想要这个输出:

prevPos[1]=hello
prevPos[2]=123
评论
猜不透o
猜不透o

请替换为以下内容并尝试

        for (int i = 0; i < textBox_ReceievedData.Lines.Length; i++)
        {

            System.Console.WriteLine("Each Line "  +textBox_ReceievedData.Lines[i]);
        }
点赞
评论