views:

114

answers:

2

Is there a way to write in Visual Studio in nice formated way the row bellow?

string x = "<Site name=\"Stack Overflow\" >Inner Content</Site>";

so that it would look like:

string x= "<Site name="Stack Overflow">
           Inner content;
          </Site>"
+6  A: 

Have you tried using a string literal?

string x= @"<Site name=""Stack Overflow"">
           Inner content;
          </Site>"

I'm not entirely sure that's what you're asking for though. Are you looking to see if you can get Visual Studio to format the code to look that way? If so there is no way to do this in the C# Editor.

JaredPar
@Jenea, Just cuaght that and escaped the quotes.
JaredPar
That's right. Thaks a lot.
Jenea
+1  A: 

I am not 100% sure what you are looking for. If you want it to look good in VS you can do something like this:

string x = "<Site name=\"Stack Overflow\">" + 
           "Inner Content" + 
           "</Site>";

I am pretty sure you need the escaping for quotes in C++/C#. I don't know of any way to avoid it, short of loading it a character at a time.

If you want to add the returns to the resulting string you can just at \n like this:

string x = "<Site name=\"Stack Overflow\">\nInner Content\n</Site>";
John Christman