在 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

更新于: 20-6 月-2020

968 次浏览

开启您的职业生涯

完成课程即可获得认证

开始
广告
© . All rights reserved.