+ 3

PROTECTED

So does this mean that you can access a protected variable online from a derived class whose base class has the said variable and you cannot access it directly from an object of the derived class?

18th May 2020, 9:35 AM
Idundun Sydney
Idundun Sydney - avatar
1 Odpowiedź
+ 1
Yes that is true. Please watch kudenvat on Youtube. He is very good. https://www.youtube.com/watch?v=G238zPCJBu4 Protected is not public you cannot do this in the main class Customer C1 = new Customer(); Console.WriteLine(C1.ID) (6.17 in video) It is almost private. But if you derive a a class from customer (7.36 in video) public class Corporate Customer : Customer { public void PrintID { CorporateCustomer CC = new CorporateCustomer(); Console.WriteLine(CC.ID); } } You are allowed to access ID because CorporateCustomer is derived from the customer class.
18th May 2020, 9:56 PM
sneeze
sneeze - avatar