4b0
4b0

Reputation: 22323

Using @ symbol in string

This link says that:

The @ symbol tells the string constructor to ignore escape characters and line breaks.

I try to append contain in StringBuilder like this.

   StringBuilder sb = new StringBuilder();
   sb.Append(@"<test name="test_all">");

But it gives an error in test_all.

I got a solution for this using single quotes. ' ':

sb.Append("<test name='layout_all'>");

But I don't understand as per document why " " does not work. Or am I missing something to understand?

Upvotes: 5

Views: 368

Answers (1)

Oded
Oded

Reputation: 499002

Well, " still has a special meaning in a verbatim string literal - you need to escape it, but in this case, you simply double it:

sb.Append(@"<test name=""test_all"">");

Upvotes: 17

Related Questions