Line inside line Ex: pie = "He said hello" - C #

In Visual Studio C #, how can I declare a string inside such a string? I saw several pages, such as "Java string inside a string in a string", but did not think that any of them coincided with my question.

In principle, if I

"<?xml version="1.0" encoding="UTF-8"standalone="yes" ?>" 

How can I declare this or something like this in my code as a string? Someone offered me double quotes around things like "1.0", but I couldn't get this to work.

Thanks for the help.

+6
string c # escaping
source share
5 answers

Or exit the double quotes, like this:

 "<?xml version=\"1.0\" encoding=\"UTF-8\"standalone=\"yes\" ?>" 

or use a shorthand line (note the main @ character before the line) as follows:

 @"<?xml version=""1.0"" encoding=""UTF-8""standalone=""yes"" ?>" 
+16
source share

Or:

 @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>" 

or

 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>" 

or more simply; use single quotes!

 "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>" 
+6
source share
 String myString = "<?xml version=\"1.0\" encoding=\"UTF-8\"standalone=\"yes\" ?>"; 
+2
source share

Try the following:

 string myString = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>" 
0
source share
0
source share

All Articles