简体   繁体   English

对于c#中的静态变量,“this”是否等效?

[英]Are there equivalents to “this” for static variables in c#

I was wondering if I can make my code clearer by indicating one variable is a static class variable. 我想知道我是否可以通过指示一个变量是静态类变量来使我的代码更清晰。 If it wasn't static I could use this.variableName, and everyone would look at it and immediately know that. 如果它不是静态的,我可以使用this.variableName,每个人都会看着它并立即知道。

I know I could adopt a naming convention like s_variableName, but that seems a little odd to me and increases the learning curve of the code. 我知道我可以采用像s_variableName这样的命名约定,但这对我来说似乎有点奇怪,并增加了代码的学习曲线。

Is there an equivalent of "this" for static variables? 静态变量是否有“this”的等价物?

使用类型名称对其进行限定:

TypeName.staticVariableName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM