Creating a literal

image_pdfimage_print

   



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 
eal test";

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


This entry was posted in Data Types. Bookmark the permalink.