[英]C# Calling Base Class Constructor
public CArm(Vector3 at, string name) : base(name)
{
}
Is there any other way to call base parent constructor within the brackets instead of doing : base(name)
? 有没有其他方法可以在括号内调用基本父构造函数而不是执行
: base(name)
?
I'm not sure if this was another language but I recall something like super();
我不确定这是否是另一种语言,但我记得像
super();
inside of the constructor to call the base class. 在构造函数内部调用基类。
Thanks. 谢谢。
No, you cannot call base constructors inside constructor bodies in C#. 不,您不能在C#中的构造函数体内调用基础构造函数。 You're probably thinking of Java's syntax.
您可能正在考虑Java的语法。
You can emulate the desired behavior by calling a method instead. 您可以通过调用方法来模拟所需的行为。 Just make sure to be very careful about calling virtual methods!
请确保在调用虚拟方法时要非常小心!
no, you can't . 不,你不能。 super keyword is used in java for calling superclass methods and objects.
super关键字在java中用于调用超类方法和对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.