我试图在发现逗号时将字符串拆分为单独的字符串变量。
string[] dates = line.Split(',');
foreach (string comma in dates)
{
string x = // String on the left of the comma
string y = // String on the right of the comma
}
我需要能够为逗号两边的字符串创建一个字符串变量。谢谢。
最佳答案
在这种情况下去掉 ForEach。
只是:
string x = dates[0];
string y = dates[1];
关于C# 将字符串拆分为单独的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7378028/