View Single Post
  #2 (permalink)  
Old February 16th, 2011, 01:21 AM
DrPurdum DrPurdum is offline
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default

Hi scolty:

You're probably right...not the most clear piece of writing. My point is that a property does not have to be a resolved data type, like an int, or float, or double. An object's property can hold another object. In this example, the textbox object holds a number of properties, of which the Text property is but one of many properties encased in the textbox object. However, the chain of information of the Text property does not end with:

textbox.Text

We already know that in C#, any text that appears in the program is actually a string object. As you saw on page 108, we can write:

int len;
string zip = "80122";
len = zip.Length;

Because a property of all strings is Length, and Text in a textbox object is a string object, we can determine the length of Text by reading the length of the text string:

len = txtInput.Text.Length;

Note that we have two dot operators here. All that means is that we are getting a property of an object that's within another object. Look back to Figure 2-6 and 2-7. In Figure 2-7, if we're inside a object looking at "Issy", we're looking at a string. While we're "inside" clsperson, we can take our wheelbarrow, press the dot operator for the "Issy" string and read the Length of that string.

Too many students choke when they see more than one dot operator. Just keep this in mind: Any time you see a dot operator, it's like going one level deeper towards the center of an onion. To peer deeper into an object requires "pressing" the dot operator to open the door and enter the next layer of the onion. When OOP was first starting, I can remember using a database object that had 13 (yes, thirteen!) dot operators to go through before you exhausted all layers on the primary object. (Poorly designed, in my opinion.)

It's pretty late, so this may not be the clearest explanation, but it's the best I can come up with right now. Read this post a few times while looking at Figure 2-7 and then go back and read page 108 and see if it makes more sense. If not, let me know.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
The Following User Says Thank You to DrPurdum For This Useful Post:
scolty (February 16th, 2011)