xxxxxxxxxx
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
In this code, a new instance of MyDerivedClass is created with a value of 42 passed to the constructor. The value of MyProperty is then accessed and printed to the console.
xxxxxxxxxx
public class MyBaseClass {
MyBaseClass(T input) {
input.doSomething();
}
}
public class MyClass : MyBaseClass {
public MyClass() : base(input) {
//other stuff here
}
}
xxxxxxxxxx
public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}