4.2. Declaring Methods
Let's talk in a bit more detail about how we specify an object's behaviors. Recall from Chapter 3 that an object's methods may be thought of as operations that the object can perform. In order for an object A to request some operation of an object B, A needs to know the specific language with which to communicate with B. That is:
Object A needs to be clear as to exactly which of B's methods/operations A wants B to perform. Think of yourself as object A and a pet dog as object B. Do you want your dog to sit? Stay? Heel? Fetch?
Depending on the method request, object A may need to give B some additional information so that B knows exactly how to proceed. If you tell your dog to fetch, the dog needs to know what to fetch: ...
Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.