我是 C# 新手并正在尝试它。
Form
我有一个带有属性的超类FormID
。Form
被其他 4 个子类继承。
Form-> DeployForm -> SystemOut
和
Form_> Colection -> SystemIn
。
如何FormID
从子类访问该属性?( DeployForm
, SystemOutColection
,Collectiom
和SystemIn
?)
// Superclass - Form.
public class Form
{
private int _FormID;
private string _UserName;
private string _ComputerName;
private string _AssetTag;
private string _Department;
private string _Status;
// Below are the associations I linked
// to other classes that don't require attribute FormID.
private FormCategory _differentiateBy;
private CheckList _referencesToChecklist;
private Staff _referencesToStaff;
public Form()
{
_differentiateBy = new FormCategory();
_referencesToChecklist = new CheckList();
_referencesToStaff = new Staff();
}
public int FormID
{
get { return _FormID; }
set { _FormID = value; }
}
}
// Sub Class - DeploymentForm
public class DeploymentForm : Form
{
private DateTime _DeployDate;
private int _DeployBy;
private DateTime _SetupDate;
private int _SetupBy;
public DeploymentForm()
{
}
public DateTime DeployDate
{
get { return _DeployDate; }
set { _DeployDate = value; }
}
public int DeployBy
{
get { return _DeployBy; }
set { _DeployBy = value; }
}
public DateTime SetupDate
{
get { return _SetupDate; }
set { _SetupDate = value; }
}
public int SetupBy
{
get { return _SetupBy; }
set { _SetupBy = value; }
}
}
// etc...