Search code examples
c#classargumentsowner

C#: What does 'owner' mean when used as argument of a class?


In the class below what does the "owner" argument do to both myClass and the base class?

public class Base
{
    public myClass(owner) : base (owner) { }
}

Solution

  • If you have two classes, one is a base class the other a derived class, when you create constructor for the derived class, you can pass arguments to the base clas.

    public class Base
    {
        private string Test = "";
    
        public Base(string test)
        {
            Test = test;
        }
    }
    
    public class Derived : Base
    {
        public Derived(string test) : base(test) // - This will call public Base(string test)
        {
        }
    }