C# Code Samples by Patrik

How to define multiline String Literal in C#

Let’s say the string is −

Welcome User, Kindly wait for the image to load

For multiline String Literal, firstly set it like the following statement using@ prefix −

string str = @"Welcome User,
Kindly wait for the image to
load";

Now let us display the result. The string is a multi-line string now

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

Comments

Leave a Comment

All fields are required. Your email address will not be published.