Additional Topics on Inheritance

Discover more details of working with inheritance in .NET

Access the base class members

Inheritance is great, but what exactly do we inherit? All members of the base class or only some of them? We can answer these questions by trying to access base class members. Let’s consider an example:

public class EducationalOrganization
{
	private string _name;
	public string Name 
	{
		get { return _name; }
	}
}

public class School : EducationalOrganization
{
}

The School class inherits from EducationalOrganization. It’s reasonable to assume that School inherits all members of EducationalOrganization, including the _name field.

Get hands-on with 1200+ tech skills courses.