Chapter 6 - Building Your Own Types with Object-Oriented Programming
- What are the four access modifiers and what do they do?
private
: This modifier makes a member only visible inside the class.internal
: This modifier makes a member only visible inside the class or within the same assembly.protected
: This modifier makes a member only visible inside the class or derived classes.public
: This modifier makes a member visible everywhere.
- What is the difference between the
static
,const
, andreadonly
keywords?static
: This keyword makes the member shared by all instances and accessed through the type.const
: This keyword makes a field a fixed literal value that should never change.readonly
: This keyword makes a field that can only be assigned at runtime ...
Get C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.