Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Calling Base Class Constructor

Tags:

c#

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)?

I'm not sure if this was another language but I recall something like super(); inside of the constructor to call the base class.

Thanks.

like image 743
RoR Avatar asked Nov 18 '10 07:11

RoR


2 Answers

No, you cannot call base constructors inside constructor bodies in C#. You're probably thinking of Java's syntax.

You can emulate the desired behavior by calling a method instead. Just make sure to be very careful about calling virtual methods!

like image 63
Jonas Høgh Avatar answered Sep 18 '22 17:09

Jonas Høgh


no, you can't . super keyword is used in java for calling superclass methods and objects.

like image 26
Nikki Avatar answered Sep 16 '22 17:09

Nikki