What does the @ prefix do on string literals in C#?

I read some c# article to combine a path using Path.Combine(part1,part2). it uses

string part1 = @"c:\temp";
string part2 = @"assembly.txt";

I don't know what is the use of @ in part1 and part2.

Answers


@ is not related to any method.

It means that you don't need to escape special characters in the string following to the symbol:

@"c:\temp"

is equal to

"c:\\temp"

Such string is called 'verbatim' or @-quoted. See MSDN.


Need Your Help

What is the best practice for using Android JNI and fragments?

android android-fragments jni

What is the best practice for using JNI to call into an application which uses fragments?

Groovy @CompileStatic and Grails

performance grails groovy-2

Looking at article on DZone about improved performance with Groovy2 when compiling with @CompileStatic annotation, I wonder to what extent can I take advantage of it? I'm guessing annotate contro...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.