我有一个名为 Names.txt 和以下数据的文件管理器
David One And Two/Three
Alex One Two Four And Five/Six
Amanda Two Seven/Ten
Micheal Seven/Nine
这是我的代码:
string[] Name = File.ReadAllLines("Names.txt", Encoding.Default);
我想将每一行作为字符串返回我的意思
"David One And Two/Three" as one string
"Alex One Two Four And Five/Six" as one string
"Amanda Two Seven/Ten" as one string
"Micheal Seven/Nine" as one string ..
我的意思是当我跑步时
for(int i = 0; i < Name.Length, i++)
{
Consol.WriteLine(Name[i]);
}
和输出应该是
David One And Two/Three
Alex One Two Four And Five/Six
Amanda Two Seven/Ten
Micheal Seven/Nine
但我得到的是
David One
Alex
Amanda Two
Micheal
和 Consol.WriteLine(Name.Length) 应该是 4 但我得到 6 我不知道为什么。即使文件为空,我也会得到 Name.Length 6
我的意思是如果它是这样的
string[] Name = {"David One And Two/Three", "Alex One Two Four And Five/Six", "Amanda Two Seven/Ten", "Micheal Seven/Nine"};
请帮助我我做错了什么?我在 Console 和 windowsForm 中尝试过,但同样的问题