更新时间:2023-02-12 18:57:24
拆分不这样的工作!
可能你想要的是:
Split doesn't work like that!
Possibly what you want is:
int count = 0;
foreach (string item in list)
{
string[] arr1 = item.Split(new char[] {'"'}, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in arr1)
{
Console.WriteLine(s);
count = count + 1;
}
}
问题不是很清楚。但是,String.split
返回一个数组,因此你不能将结果存储在arr1 [count]
中,因为那是一个字符串
参考。不是字符串[]
引用。同样为什么要打印item
在下一行,而不是一些拆分数据?您可能需要执行以下操作:
The issue is not really clear. However,String.split
returns an array, so you cannot store the result inarr1[count]
, since that is astring
reference. not astring[]
reference. Similarly why are you printingitem
in the next line, rather that some split data? You probably need to do something like:
foreach (string item in list)
{
string[] splits = item.Split(new Char[] { '"','"' });
// do something with the split subitems
}
目前还不清楚你想用这个代码做什么,但它可以简化。
It is not clear what you want to do with this code, but it can be simplified.
int count = 0;
string[] arr1 = new string[reply.Length-20];
foreach (string item in list)
{
arr1[count] = item.Split(new Char[] { '"','"' });
Console.WriteLine(item);
count = count + 1;
}
您对变量 count