using System;
using System.Collections.Generic;
using System.Text;
class BaseClass
{
public virtual void method()
{ Console.WriteLine("BaseClass method"); }
}
class SubClass : BaseClass
{
public override void method()
{ Console.WriteLine("SubClass method"); }
public void someMethod()
{ Console.WriteLine(); }
static void Main(string[] args)
{
BaseClass var = new SubClass();
var.method();
var.someMethod();
}
}
The above code does not compile because var's type is BaseClass. Although var is an object of SubClass which contains the someMethod(). Could someone help. Thanks in advance.