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