Yes, this should work fully as expected, even if your sample code is not entirely clear (what is t ?). Let me give you another example.
class Base { public int x = 3; public int GetValue() { return x * 5; } } class Derived : Base { public Derived() { x = 4; } }
If we use Base :
var b = new Base(); Console.WriteLine(b.GetValue());
... and if we use Derived :
var d = new Derived(); Console.WriteLine(d.GetValue());
It should be noted that if x used in the Base constructor, setting it in the Derived constructor will have no effect:
class Base { public int x = 3; private int xAndFour; public Base() { xAndFour = x + 4; } public int GetValue() { return xAndFour; } } class Derived : Base { public Derived() { x = 4; } }
In the above code example, GetValue will return 7 for Base and Derived .
source share