C# 中的字串文字上的 @ 字首會起什麼作用?
@ 字首說明,無需轉義符號後面的字串中的特殊字元。
以下語句
@"D:
ew"
等同於
"D:\
ew"
如果您想要有較長的字串並希望它跨多行顯示,也會使用 @ 字首。以下是顯示多行字串示例 −
示例
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
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP