From the course: Advanced C#: Object-Oriented Programming
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Access modifiers - C# Tutorial
From the course: Advanced C#: Object-Oriented Programming
Access modifiers
- [Instructor] When you create a class in C#, all of the members of that class have a specific level of accessibility by other parts of your code. So, it's important to understand how this works. So let's open the code for this example in our AccessModifiers folder. I'll open up the program, and I'll open up the Modifiers.cs file. So I have a class defined, and each item in the class has an access modifier as part of its definition. The "public" keyword means that that particular member can be accessed from any other part of your program's code. So this class has three public items: The constructor, which is usually public, because classes are often created by other parts of the program. This function right here, Func1, and then there's a property, if we look down here, this data property is also defined as public. Properties are usually used to expose internal data, so again, they're also often declared as public.…