OOP

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var v = new Derived();
            int x = 18;
            v.Foo(x);
        }
    }

    public class Base
    {
        public virtual void Foo(int x)
        {
            Console.WriteLine("In Base.foo");
        }
    }

    public class Derived : Base
    {
        public override void Foo(int x)
        {
            Console.WriteLine("In Derived.Foo(int x)");
        }

        public void Foo(object o)
        {
            Console.WriteLine("In Foo(object o)");
        }
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s