From the course: Learning C#

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Access modifiers

Access modifiers - C# Tutorial

From the course: Learning C#

Access modifiers

- Let's take a closer look at how access modifiers work in C-sharp classes. These keywords let us control how the code and data within our class definitions are exposed to other parts of our program. Now, so far in this course, you might have noticed that some of the methods that we've been working with in our classes have the keyword "public" in their definitions. And you might be curious about what that means. The public keyword means that the method or class member can be accessed by any other code within your program. So there are a couple of other keywords we're going to try out in this example as well. "Protected" means that the method or class member can be accessed by other code within the class itself or within any derived subclasses. And "private" means that the method or class member can only be accessed within that class definition. And this is the default setting. Now, these are not the only access modifiers,…

Contents