如何为属性创建公共(public) getter 和私有(private) setter?以下是正确的吗?
public String Password
{
set { this._password = value; }
}
private String Password
{
get { return this._password; }
}
最佳答案
是的,即使使用自动属性也是可能的。我经常使用:
public int MyProperty { get; private set; }
关于c# - 在 C# 中是否可以使用同名的公共(public) getter 和私有(private) setter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6082551/