我在字符串数组中插入字符串元素时遇到问题...例如,我有三个赋值行:
a = b
b = c
c = e
然后我想把这六个变量插入到string[]
变量中。
我使用了下面的代码,但是这段代码只插入了最后一个赋值变量 (c, e)。
for (int i = 0; i < S; i++) // S = 3 number of assignment line
{
variables = assigmnent_lines[i].Split('=');
}
最佳答案
List<string> this_is_a_list_of_strings = new List<string>();
foreach (string line in assignment_lines)
{
this_is_a_list_of_strings.AddRange(line.Split('='));
}
string[] strArray = this_is_a_list_of_strings.ToArray();
关于c# - C#中的字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8620629/