一.get set方法和普通方法
//方法
Java方法
public string GetName() { return this.Name; }
public void SetName(String Name) { this.Name=Name; }
C#方法
public string _Name//属性
{
get { return Name; }
set { Name = value; }
}
二.get set方法提供验证,只读只写
private string _Name;
public string Name
{
get { return _Name; }
set {
if (string.IsNullOrEmpty(value))
{
throw new ArgumentNullException();//提供验证,只读只写
}
}
}
三.this的用途