Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Cách định nghĩa chuỗi nhiều dòng (Multiline String Literal) trong C#

Giả sử chuỗi:

Welcome User, Kindly wait for the image to load

Để multiline string literal, dùng @ prefix:

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

Hiển thị kết quả, chuỗi giờ là multi-line:

Ví dụ

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); 
        } 
    } 
}

Kết quả

Welcome User,
            Kindly wait for the image to
            load