什么是@ preFIX做字符串在C#中?字符串、preFIX

2023-09-02 01:57:12 作者:风尘乱世

我读了一些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 。

 
精彩推荐
图片推荐