课程: Learning C#

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Access modifiers

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,…

内容