Good day!
I’m wondering if it’s possible to assign multiple different types of arguments when instantiating a class.
Here’s an example of what I have right now
public Unit(Vector2 Position, Color col)
{
this.position = Position;
this.color = col;
}
Notice how it needs both a Vec2 & Color, I’m wondering if it’s possible to do it so I can choose between either ONLY one argument or both example follows below.
1
public Unit(Vector2 Position)
{
this.position = Position;
this.color = Color.White;
}
2
public Unit(Vector2 Position, Color col)
{
this.position = Position;
this.color = col;
}
Sure you can overload constructors exactly like that. I would suggest making one overload call the other though: