且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C#中的字符串数组

更新时间:2023-02-12 17:08:51

 列表<串GT; this_is_a_list_of_strings =新的List<串GT;();
的foreach(在assignment_lines串线)
{
    this_is_a_list_of_strings.AddRange(line.Split('='));
}
字符串[] = strArray this_is_a_list_of_strings.ToArray();

I have a problem inserting string elements in a string array... For example, I have a three assignment lines:

a = b
b = c
c = e

Then I want to insert these six variables in string[] variables.

I use the following code, but this code inserts only the last assignment variables (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();