Using Object-Orientation in ASP.NET : Encapsulation, Part 2By Ian Stallings
In Part 1 we examined the basics of encapsulation and a simple
In this page we'll examine how to utlize this class (thereby showing the benefits of encapsulation)!
For our example, we'll call this class from our ASP.NET file using the following code:
This should produce the following output:
Notice that when we did not alter the state of the object directly. Instead we called a behavior of the object
setPhoneNumber. We aren't worried about how this is accomplished. That's the great part. It
hides the implementation details. For all we know there could be a "Hamster in a Wheel" class that makes this
And that wraps up encapsulation. In our next article we will discuss inheritance and how it can be used to develop ASP.NET to create reusable and extensible code.