- Home /
Question by
YTGameDevDave · Jan 18, 2018 at 09:57 AM ·
c#runtimeclassconstructorat
Adding parameter to instance of a class during runtime
So here I have a constructor from the class "Existence".
public Existence (string _name, int _dayborn, int _monthborn, int _yearborn)
{
name = _name;
dayborn = _dayborn;
monthborn = _monthborn;
yearborn = _yearborn;
}
so I'll make an instance of the class using the constructor above
Existence player;
player = new Existence ("Charles", 1, 3, 1991);
I'll be able to access and change those attributes if I want to during runtime.
But what if during Runtime I want to add an extra parameter to this instance? Like let's say, Haircut...
How would I do this? Recreate the constructor and the instance? Please help
Comment