Hi, I have a question regarding Methods.
I have a method that takes a base class. I am getting an Error when I pass class that is derived of the base to it.
For Example
Class TaskToRun
{
public virtual void run ();
}
Class SayHi : TaskToRun
{
public run()
{
Console.WriteLine("Hi");
}
Now I can't pass SayHi to a method that takes TaskToRun as its parameter:
RunTask(TaskToRun task)
{
delegate void MethodToRun();
MethodToRun methodtorun = new MethodToRun(task.run);
methodtorun();
}
Thank you so much for any help!