Computer >> Computer tutorials >  >> Programming >> C#

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


The @prefix states hat you don't need to escape special characters in the string following to the symbol.

The following statement

@"D:\new"

is equal to:

"D:\\new"

The @ prefix is also used if you want to have large strings and want it to be displayed across multiple lines. The following is an example showing multi-line string −

Example

using System;

namespace Demo {

   class Program {

      static void Main(string[] args) {
         string str = @"Welcome User,
         Kindly wait for the image to
         load";

         Console.WriteLine(str);
      }
   }
}

Output

Welcome User,
Kindly wait for the image to
load