base keyword in constructor c# - Google Search

PHOTO EMBED

Thu Jun 29 2023 16:05:37 GMT+0000 (Coordinated Universal Time)

Saved by @destinyChuck #csharp

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
content_copyCOPY

https://www.google.com/search?q