Is there any way to manipulate variables passed in to a child class constructor before passing it of
- by Matt
Hi,
Is there any way to delay calling a superclass constructor so you can manipulate the variables first?
Eg.
public class ParentClass
{
private int someVar;
public ParentClass(int someVar)
{
this.someVar = someVar;
}
}
public class ChildClass : ParentClass
{
public ChildClass(int someVar) : base(someVar)
{
someVar = someVar + 1
}
}
I want to be able to send the new value for someVar (someVar + 1) to the base class constructor rather than the one passed in to the ChildClass constructor. Is there any way to do this?
Thanks,
Matt