Writeline没有将某些选项卡写入输出文件

时间:2013-02-14 23:10:48

标签: c# string-formatting delimiter

我正在尝试使用类似于以下内容的数据编写制表符分隔的文本文件:

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

为什么不插入这两个标签,我该怎么做才能确保它们正确插入?

1 个答案:

答案 0 :(得分:1)

也许这些标签变得太小,因为前面的值太宽了?

0   1   2   15  162 102819201924
.   .   .   .   .   .   .   .