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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter