public class MyBaseClass
{
private int _myProperty;
public MyBaseClass(int value)
{
_myProperty = value;
}
public int MyProperty
{
get { return _myProperty; }
set { _myProperty = value; }
}
}
public class MyDerivedClass : MyBaseClass
{
public MyDerivedClass(int value) : base(value)
{
// additional initialization logic for MyDerivedClass
}
}
//To create an instance of MyDerivedClass and set its MyProperty value using the constructor, you can use the following code:
var obj = new MyDerivedClass(42);
Console.WriteLine(obj.MyProperty); // prints 42