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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP