【发布时间】:2015-05-01 02:13:47
【问题描述】:
我可以从员工类中的人员类创建一个对象,并使用我在员工类中创建的人员对象通过员工类访问类人员的方法和成员吗
public class Person
{
protected string _name;
public int _age;
public string Name
{
get { return _name; }
set { _name = value; }
}
public int Age
{
get { return _age; }
set { _age = value; }
}
}
class Employee
{
Person person = new Person();
}
【问题讨论】:
-
是的,你可以。问之前有没有试过?
-
为什么不只是
public class Employee { public Person PersionalInfo {get; set;} /* other Employee properties*/ }