@ 前缀对 C# 中的字符串文字有什么作用 [英] What does the @ prefix do on string literals in C#

查看:14
本文介绍了@ 前缀对 C# 中的字符串文字有什么作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了一些 C# 文章以使用 Path.Combine(part1,part2) 组合路径.

I read some C# article to combine a path using Path.Combine(part1,part2).

它使用以下内容:

string part1 = @"c:	emp";
string part2 = @"assembly.txt";

我可以知道part1和part2中@的作用是什么?

May I know what is the use of @ in part1 and part2?

推荐答案

@ 与任何方法无关.

这意味着您不需要对符号后面的字符串中的特殊字符进行转义:

It means that you don't need to escape special characters in the string following to the symbol:

@"c:	emp"

等于

"c:\temp"

这样的字符串被称为逐字"或@引用.请参阅 MSDN.

Such string is called 'verbatim' or @-quoted. See MSDN.

这篇关于@ 前缀对 C# 中的字符串文字有什么作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆