【发布时间】:2018-04-26 20:38:34
【问题描述】:
我有一个获取 SubForm 对象并显示它的方法。
public void subFormLauncher(object sender, SubForm f)
{
if (f == null)
{
f = new SubForm(this); // This line is problematic
f.Show();
}
else
{
if (!f.Visible)
{
f.Show();
}
f.Activate();
}
}
VS 很生气,因为 SubForm 是一个抽象类,而我不小心实例化了它的一个实例(公平)。
public abstract class SubForm : Form
{
public SubForm(frmMain f) { }
public abstract void InitForm();
}
有没有办法在 subFormLauncher 的参数中指定我想要 SubForm 的子级?比如:
public void subFormLauncher(object sender, <T> extends SubForm f)
【问题讨论】:
标签: c# oop abstract-class