谁能告诉我两者之间的区别
public class Vendor
{
public string VendorName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和
public class Vendor
{
private string vendorName = string.Empty;
public string VendorName
{
get { return vendorName; }
set { vendorName = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
使用私有变量有什么好处吗?这样做只会浪费时间和线条吗?在课堂上没有对该属性进行任何操作.
谢谢