有什么区别
class abc : qwe
{
}
Run Code Online (Sandbox Code Playgroud)
和
class zxc : qwe
{
zxc() : base(new someAnotherclass()).
{
}
}
Run Code Online (Sandbox Code Playgroud)
Giu*_*uto 10
区别在于,在您的第一个代码片段中,您正在调用无参数基类构造函数,而在您的第二个代码段中,您将使用参数调用基类构造函数.
您的基类可能定义如下:
class qwe{
public qwe(){ /* Some code */ }
public qwe(SomeAnotherclass ac){ /* Some other code */ }
}
Run Code Online (Sandbox Code Playgroud)
您的abc类的默认构造函数与以下内容完全相同:
class abc{
public abc() : base() {}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
285 次 |
| 最近记录: |