new line in a multi-line string

Posted by Zka on Stack Overflow See other posts from Stack Overflow or by Zka
Published on 2010-04-13T09:41:40Z Indexed on 2010/04/13 9:42 UTC
Read the original article Hit count: 396

Filed under:
|
|

Trying to override a tostring in one of my classes.

 return string.Format(@" name = {0}
                         ID = {1}
                         sec nr = {2}
                         acc nr = {3}", string, int, int ,int); // types

But the thing is, the result isn't aligned when printed out:

name = test
                                   ID = 42
                                   sec nr = 11
                                   acc nr = 55

Trying to add \n just prints it out without formating. Guessing it has something to do with @"" which I'm using for multi-lining.

Would like it to print out :

name = test
ID = 42
sec nr = 11
acc nr = 55

© Stack Overflow or respective owner

Related posts about c#

Related posts about string