如何在 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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP