为什么我们在变量名中使用_?
问题描述:
我见过像 _ image 这样的变量,想知道 _ 是什么意思?
I have seen variables like _ image and was wondering what _ meant?
答
它不意味着任何事情.将私有成员变量与方法和公共属性分开是一种常见的命名约定.例如:
It doesn't mean anything. It is rather a common naming convention for private member variables to keep them separated from methods and public properties. For example:
class Foo
{
private int _counter;
public int GetCounter()
{
return _counter;
}
public int SetCounter(int counter)
{
_counter = counter;
}
}