【发布时间】:2012-08-04 01:22:27
【问题描述】:
我有 2 个不同的小部件,它们共享 10 个相同的成员。但是它们也有 2 个阶段。 每个阶段都有其他阶段没有的特定成员。
public class widget
private _id as integer
private _engravedId as string
private _stage as WidgetStage
private _wig as IWidget
end class
public interface IWidget
Calculate()
end interface
public class Twidget
implemets IWidget
private t as integer
private b as double
private d as double
end class
public class Rwidget
implemenents IWidget
private y as integer
private x as double
private b as double
end class
如果我在我的类中声明一个 Iwidget,那么我将不得不强制转换它以访问派生类变量。有没有更好的办法?
【问题讨论】:
-
如果附加变量是私有的,即使你转换了,你又如何访问它们?
标签: .net vb.net .net-4.0 private-members