O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.3. Controlling Access to Members

The access modifiers public and private control access to a class’s variables, methods and properties. (In Chapter 11, we’ll introduce the additional access modifier protected.) As we stated in Section 10.2, the primary purpose of public methods is to present to the class’s clients a view of the services the class provides (that is, the class’s public interface). Clients of the class need not be concerned with how the class accomplishes its tasks. For this reason, a class’s private variables, properties and methods (i.e., the class’s implementation details) are not directly accessible to the class’s clients.

Figure 10.3 demonstrates that private class members are not directly accessible outside the class. Lines ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required