Stupid question. So there is the code:
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public void Method()
{
Console.WriteLine("Hello, I'm person!");
}
}
class Student : Person
{
//
}
Main
Student student = new Student();
Person p = student;
Console.WriteLine(p.GetType()); // Student
Why does this return a Student
? I thought that it should be Person
, because we created Person
instance and insert into it Student
object