Creating a literal : Literal « Data Types « C# / C Sharp






Creating a literal

Creating a literal


using System;

class Test {

   public static void Main() {
     // Create a simple string literal
     string s1 = "This is a test";

     // Create a string literal with an escaped character
     string s2 = "This is a \"real\" test";

     // Create a string literal with the @ sign
     string s3 = @"This is a \real\ test";

     // Output them
     Console.WriteLine("String 1 = {0}", s1 );
     Console.WriteLine("String 2 = {0}", s2 );
     Console.WriteLine("String 3 = {0}", s3 );
  }
}
           
       








Related examples in the same category

1.String literalsString literals