在C#变量名前面放置一个@?(What does placing a @ in front of a C# variable name do? [duplicate])
这个问题已经在这里有一个答案:
C#中变量名称中的@字符的用途/含义是什么? 9个答案我一直在使用一些C#的遗留代码,我在变量名前面看到很多@符号。 这意味着什么?
目前,我在变量前面看到很多没有保留的通用名称。 例如:
MyProcedure(@step.LoadInstanceId, @step.ResultCode, @step.StatusCode);鉴于这一步不是一个保留词,有没有理由应该逃避?
This question already has an answer here:
What's the use/meaning of the @ character in variable names in C#? 9 answersI've been working with some C# legacy code and I've been seeing a lot of @ symbols in front of variable names. What does this signify or do?
Currently I'm seeing it a lot in front of variables with common names that aren't reserved. E.g.:
MyProcedure(@step.LoadInstanceId, @step.ResultCode, @step.StatusCode);Given that step isn't a reserved word, is there any reason that they should be escaped?
最满意答案
这只是一种允许将保留关键字声明为var的方法。
void Foo(int @string)It's just a way to allow declaring reserved keywords as vars.
void Foo(int @string)更多推荐
发布评论