How to define multiline String Literal in C#?

CsharpProgrammingServer Side Programming

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

 Live Demo

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
raja
Published on 07-Aug-2018 12:28:15
Advertisements