如何在 C# 中定义多行字符串常量?
假设字符串如下所示 −
Welcome User, Kindly wait for the image to load
对于多行字符串常量,首先使用@前缀设置如下所示 −
string str = @"Welcome User, Kindly wait for the image to load";
现在让我们显示结果。该字符串现在是一个多行字符串 −
示例
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); } } }
输出
Welcome User, Kindly wait for the image to load
广告