Visit our site: Vist and Get Free Gifts

Learn To Build: Method Overriding In C#

Visit our site: Vist and Get Free Gifts

Visit our site: Vist and Get Free Gifts

Wednesday, February 12, 2014

Method Overriding In C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MethodOverriding
{
    class baseClass
    {
        public virtual void doSomething()
        {
            Console.WriteLine("This is the baseClass saying hi!");
        }
    }

    class subClass : baseClass
    {
        public override void doSomething()
        {
            base.doSomething();
            Console.WriteLine("This is the subClass saying hi!");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            baseClass obj1 = new subClass();

            obj1.doSomething();

            Console.ReadLine();
        }
    }
}

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home