Hi, Can anybody help me to how we can use base class constructor/methods in deriverd class without creating an instance of base class.

 public class abc
        {
            public abc()
            {
            }
            public void aa()
            {
                MessageBox.Show("base");
            }
            public static string aabb()
            {
                MessageBox.Show("base1");
            }
        }
        public class bcd : abc
        {
          //use above methods
        }

here i doing like this,

public class abc
        {
            public abc(int bb)
            {
                bb = 10;
            }
            public static int  aa(int a)
            {      
         
                MessageBox.Show(a);
            }        
         
        }
        public class bcd : abc
        {
            public bcd (int bb)
            {
                base(bb);
            }
        }

The constructor of your derived class, should call the constructor like:

public bcd(int bb) : base(bb)
{
}

You can normally call a base class' methods as if they were the derived class' methods. However, if you override or hide a base class' method, you can call it like:

base.AMethod()

.

Yep, as nmaillet showed. You have two option, or to access to class`s constructor (his 1st upper example), or to access any of your methods in your base class (his 2nd example).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.