What's the difference between:
XmlDocumentFragment docFrag = xmlDoc.CreateDocumentFragment();
docFrag.InnerXml = @myString;
and
XmlDocumentFragment docFrag = xmlDoc.CreateDocumentFragment();
docFrag.InnerXml = myString;
What's the difference between:
XmlDocumentFragment docFrag = xmlDoc.CreateDocumentFragment();
docFrag.InnerXml = @myString;
and
XmlDocumentFragment docFrag = xmlDoc.CreateDocumentFragment();
docFrag.InnerXml = myString;
The only case when you should use @
with variable name - is when variable name conflicts with keyword. E.g. if you have variable names like @string
or @class
. In this particular case you don't need to use @
.
It is possible also to declare verbatim string literals with @
symbol, but you should use string literal instead of variable in that case:
docFrag.InnerXml =
@"<foo>
<bar/>
</foo>";
Such string literals might span multiple lines, which is handy when you work with xml.