3 inheritance constructor c#-3.0
我有两个类声明如下:
class Object1
{
protected ulong guid;
protected uint type;
public Object1(ulong Guid, uint Type)
{
this.guid = Guid;
this.type = Type
}
// other details omitted
}
class Object2 : Object1
{
// details omitted
}
Run Code Online (Sandbox Code Playgroud)
在客户端代码中,我希望能够像这样创建每个对象的实例:
Object1 MyObject1 = new Object1(123456789, 555);
Object2 MyObject2 = new Object2(987654321, 111);
Run Code Online (Sandbox Code Playgroud)
我怎样才能让Object2像这样使用Object1的构造函数?谢谢.
class Object2 : Object1
{
Object2(ulong l, uint i ) : base (l, i)
{
}
}
Run Code Online (Sandbox Code Playgroud)