Possible Duplicate:
what does “@” means in c#
What does the sign @ mean in the following:
Class.Field = @"your text here";
I came across this in a piece of code, the compiler does not seem to complain... I've searched around to no avail...
What does the @ mean?
It indicates a verbatim string literal. You can use it so escapes aren't treated as such:
string path = "C:\\Documents and Settings\\UserName\\My Documents";
Becomes:
string path = @"C:\Documents and Settings\UserName\My Documents";
You can do something like
@"C:\temp\testfile.txt"
Without @ you would need to do
"C:\\temp\\testfile.txt"
Also it helps you work with other more complicated strings that should represent XML, for example.
Only one thing that you would need to double-write is " itself.
So, @"Tom said ""Hello!""";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With