C# @ modifier for methods parameters(方法参数的C#@修饰符)
问题描述
我在VS2010上使用ReSharper插件,并且正在生成一个接口方法。 ReSharper将@放在参数名称上。这是用来做什么的?
int Count(Func<ContratoList, bool> @where);
有什么不同
int Count(Func<ContratoList, bool> where);
谢谢!
推荐答案
@
符号允许您在变量名中使用reserved words。
int @class = 1;
void MyMethod(int @goto);
bool @public { get; set; }
正如Marc在他的评论和回答中正确指出的那样,ReSharper这样做实际上是错误的,因为where
是Contextual Keyword,而实际上不是保留字,所以您的方法将在没有@
的情况下编译。
这篇关于方法参数的C#@修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!