p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 (http://p2p.wrox.com/forumdisplay.php?f=409)
-   -   p114, confusion over text. (http://p2p.wrox.com/showthread.php?t=82619)

scolty February 15th, 2011 07:11 PM

p114, confusion over text.
Good evening,

I was wondering if someone could clarify the following text for me.

"Now ask yourself this question: What kind of data type is the Text property? Well, if the Text
property is storing textual data, the data must be stored in a string data type. Because the Text property
of a textbox object is a string variable, it also means the Text property is a string object ."

i understand its storing data in the type string. its the section after, especially the section stating its a string variable and why that means its a string object that i dont understand.

sorry if this seems like a stupid question but im genuinely confused so i would appreciate it if someone could elaborate on the above or point me to an earlier section in the book where i seem to have missed what was being explained.

Thanks for your time



DrPurdum February 16th, 2011 01:21 AM

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:


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.

scolty February 16th, 2011 08:49 AM

Good Afternoon,

Thanks again for your reply. Yeah i believe it makes sense now assuming the following is correct.

An object may have several properties. Each property will have a specific type associated with it, ie int, string etc BUT one or more of the objects properties may not have a fixed type because they hold objects.

If this is correct then i get it now [:)]

Thanks again for your help + your book is definately one of the best i have read on this subject. I have read a few before and had to put my aim of understanding C# on hold as i wasnt able to pick it up with their books.



DrPurdum February 16th, 2011 04:58 PM

Yep, you got it...

All times are GMT -4. The time now is 12:28 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.