C# constructor execution order

后端 未结 7 861
渐次进展
渐次进展 2020-11-22 14:57

In C#, when you do

Class(Type param1, Type param2) : base(param1) 

is the constructor of the class executed first, and then the superclass

7条回答
  •  太阳男子
    2020-11-22 15:43

    Your question is a bit unclear but I'm assuming you meant to ask the following

    When to I call the base constructor for my XNA object vs. using the impilict default constructor

    The answer to this is highly dependent on both your scenario and the underlying object. Could you clarify a bit wit the following

    • What is the scenario
    • What is the type of the base object of TerrainCollision?

    My best answer though is that in the case where you have parameters that line up with the parameters of the base class`s constructor, you should almost certainly be calling it.

提交回复
热议问题