I'm brand-new to C#. Among the samples I've seen is the use of the @ symbol in front of quoted text. What's its purpose?

For my first program, I wrote one that opens Excel workbooks for retrieval and update. In the on-line samples I found, that symbol preceded the filename samples. I omitted that symbol, though, and my program works fine - which leaves me wondering why I see samples with that symbol in them.

It means that the string is "Literal". So you can't use escape strings in it.

For example:
Console.WriteLine(@"This\nis a new line");
Output: This\nis a new line

Console.WriteLine("This\nis a new line");
Output:
This
is a new line

Too bad C and C++ doesn't have that.

Yeah, languages tend to evolve and improve. Did you also notice that the # sign in C# is in fact two + signs merged together?

Edited 3 Years Ago by ddanbe: typo

This question has already been answered. Start a new discussion instead.