How to call base class method from derived class in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class MyClass
    {
        string str;

        public void Show(string str)
        {
            this.str = str;

            Console.WriteLine(str);
        }
    }
    class MySubClass : MyClass
    {
        public void Print(string str)
        {
            Show(str);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            MySubClass mysubclass = new MySubClass();

            mysubclass.Print("C#");

        }
    }
}


/*
run:
    
C#

*/

 



answered Apr 25, 2017 by avibootz

Related questions

1 answer 230 views
1 answer 166 views
1 answer 137 views
1 answer 172 views
1 answer 150 views
1 answer 166 views
...