gpt4 book ai didi

c# - C#中的字符串数组

转载 作者:太空狗 更新时间:2023-10-30 00:56:04 25 4
gpt4 key购买 nike

我在字符串数组中插入字符串元素时遇到问题...例如,我有三个赋值行:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com