如何在 C# 中定义多行字符串文字?

csharpprogrammingserver side programming更新于 2025/5/30 2:37:17

假设字符串为 −

欢迎用户,请等待图像加载

对于多行字符串文字,首先使用@前缀 − 将其设置为以下语句

string str = @"欢迎用户,请等待图像加载";

现在让我们显示结果。该字符串现在是多行字符串 −

示例

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

相关文章