开发者

Writeline throwing "Input string was not in a correct format"

I am trying to write a number of values onto a line, like this...

try
{
    sw.WriteLine("Element               {0}     {1}     {2}     {3}     {4}     {5}     {6}     (7}     {8}",
                 "a",
                 "b",
                 "c",
                 "d",
                 "e",
                 "f",
                 "g",
                 "h",
                 "i");
}
catch (Exception ex)
{
    string mystring = ex.ToString();
}

and getting an "Input string was not in a correct format" exception for my trouble. The开发者_如何转开发 streamwriter object exists and is valid as numerous other writes are performed before this one. (In the fullness of time I will replace the "a" etc with something more useful; as soon as I get this problem sorted out.)

Can anyone see what is wrong?


Look at "(7}". You need to replace the "(" with a "{".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜