c#实体类实例 为什么是引用关系啊?
namespace BureauNews.Entity {
public class Ips {
private int id;
private string ip = String.Empty;
private string depict = String.Empty;
private int is_audit = 0;
public Ips() { }
public int Id {
get { return this.id; }
set { this.id = value; }
}
public string IP {
get { return this.ip; }
set { this.ip = value; }
}
public string Depict {
get { return this.depict; }
set { this.depict = value; }
}
public int IsAudit {
get { return this.is_audit; }
set { this.is_audit = value; }
}
}
}
Ips i = new Ips();
i.id=5;
Ips i2 = i;
i2.id=6;
这时i.id=6
为什么i2是引用i的关系,我是实例啊。
------解决方案--------------------
类是引用类型,不是值类型