Friday, 29 May 2009

How to Write Long String in Multiple Lines In c#

It is always good to have your big strings being splitted into multiple lines so that it is easy to read understand and give a professional llok of CODE.
e.g...
attachmentElement.InnerText = "Mukesh Kumar Giri is going to
show you how you can split your
big strings into small peices ";

You got have two ways to achieve it.
1.> attachmentElement.InnerText = " Mukesh Kumar Giri" +
"is going to show " +
" how you can split" +
"your big strings" +
"into small peices";
2.> attachmentElement.InnerText = @"Mukesh Kumar Giri is going to
show you how you can split your
big strings into small peices";

That is it.
Always prefer the former style as latter style does not move the next line to the starting of first line.
I had to try it while i was trying to insert multiple values in my XML and i had to struggle a lot to achieve it which does not have anything to do with XML.

Cheers,

Mukesh Giri

No comments:

Post a Comment