Hi, there,
I was doing experiment of C# OOP concepts and found a situation I can't figure it out.
I have a base class Employee and a derived class Manager. I also have a method away from the two classes, test, which takes one parameter:an instance of Employee. I instantiated an object with Employee emp1 = new Employee(); and called test(emp1), it worked perfectly. But as I instantiated another object emp2 with Employee emp2 = new Manager( ); and call test( emp2), I got error message invalid argument of test( ) method.
So I think the problem is associated with the difference between the two statements below. Can someone illuminate me?
Employee emp1 = new Employee();
Employee emp2 = new Manager();
Sample code:
Public class Employee
{
....;
}
public class Manager : Employee
{
......;
}
public void Test ( Employee emp )
{
Console.Write("...");
}