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

 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

Updated on: 20-Jun-2020

864 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements