我正在尝试编写一个制表符分隔的文本文件,其数据类似于以下内容:
ColHead1 ColHead2 ... Colhead10
Row1Dat1 Row1Dat2 ... Row1Dat10
Row2Dat1 Row2Dat2 ... Row2Dat10
但是,在调试我的代码时,我注意到有几个选项卡没有出现。这是我目前正在尝试的代码:
string columnHeaders = string.Format("ColHead1\tColHead2\tColHead3\tColHead4\tColHead5\tColHead6\tColHead7\tColHead8\tColHead9\tColHead10");
fileW.WriteLine(columnHeaders);
string row1 = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}", val1, val2, val3, val4, val5, val6, val7, val8, val9, val10);
fileW.WriteLine(row1);
string row2 = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}", val11, val12, val13, val14, val15, val16, val17, val18, val19, val20);
fileW.WriteLine(row2);
具体来说,当我查看 row1 或 row2 中的值时,它的格式如下(在任一行上):
dat1 dat2(noTabHere)dat3 dat4 dat5 dat6 dat7 dat8 dat9(noTabHere)dat10
为什么没有插入这两个选项卡,我该怎么做才能确保它们正确插入?