HomeCSharpC# Tips & Tricks #9 – Multiline String Literal in C#

C# Tips & Tricks #9 – Multiline String Literal in C#

C# multiline string literal (@) is one of the feature which allows the c# developers to use @ symbol in front the string. This lets the developers to form a verbatim string literal in C#.

How to display a multiline string literal in C# ?

All that you need to do is to use the @symbol in front of the string as shown below.

string query = @"SELECT FirstName, MiddleName , LastName
FROM Employee
WHERE FirstName ='Senthil'";

When you display this in the console window , you would notice that the string would be displayed in a multi line line.

c# multiline string

Here’s the code that is used.

public class Hello {
    public static void Main() {
        string query = @"SELECT FirstName, MiddleName , LastName
FROM Employee
WHERE FirstName ='Senthil'";
        System.Console.WriteLine(query);
    }
}

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...