【发布时间】:2020-09-10 07:53:38
【问题描述】:
所以我只是学习 C# 并尝试使用数组,我通过表单应用程序从用户那里获取输入并希望将其复制到名为 prevPos 的数组中,格式如下
接收数据(字符串):
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
【问题讨论】:
-
你为什么不使用 String [] ?