什么是@ preFIX做字符串在C#中? [英] What does the @ prefix do on string literals in C#?

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

问题描述

我读了一些C#的文章使用Path.Combine结合的路径(第一部分,第二部分)。 它采用

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

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

我不知道什么是在第1部分和第2部分使用 @

推荐答案

@ 是不相关的任何方法。

@ is not related to any method.

这意味着你不必逃避以下的符号字符串中的特殊字符:

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

@"c:\temp"

等于

"c:\\temp"

这样的字符串被称为逐字或@ -quoted。请参见 MSDN

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

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