我在 .txt 文件中有以下文本:
hello 123 example info
mello 456 xample text
yello maple syrup
我在做:
string FILENAME = Server.MapPath(".") + @"\example.txt";
string[] allLines = File.ReadAllLines(FILENAME);
string[] items = allLines[i].Split('\t');
现在,对于最后一行,我得到两个连续的空列,而不是跳过第二个(items[1])并给我第三个。
我的最终结果如下所示:
hello 123 example info
mello 456 xample text
yello
我实际上是在数据库中插入信息,但我不想详细说明,因为我知道问题出在拆分本身。
我的最终结果应该包括第三行中的第三列信息。