Created
December 23, 2014 00:49
-
-
Save nipunas/8cc4c8dc2c0900aa402b to your computer and use it in GitHub Desktop.
Access Modifiers - Protected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee : Person | |
{ | |
static void Main() | |
{ | |
Person person = new Person(); | |
//Not allowed | |
//person.Id = 1; | |
Employee employee = new Employee(); | |
employee.Id = 2; | |
} | |
} | |
class Person | |
{ | |
protected int Id { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment