Hi Peter,
Consider this:
class Items
{
public string item2;
}
now, if item3 is Length you can do
Items item1 = new Items();
Instead of doing
string s = item1.item2;
s.Length;
you can do
item1.item2.Length;
now, Length has a ToString() method so in effect you could do
item1.item2.Length.ToString();
In other words item1 has some properties, variables or methods in this
case one of them is item2.
item2 is another object with other properties variables or methods, in
this case one of them is item3.
You simply access public variables, properties, methods of the object
immediatly preceding '.' Any other '.' is irrelevant.
On Mon, 15 Nov 2004 18:28:29 +0100, Peter <An*****@work.nl> wrote:
variable, then item2 is a property on that variable which
exposes an instance,
You mean that property item2 operates on an object of class
item1.
Does next code make sense:
public class MyClass {
MyItem _item2;
public MyItem item2
{
get
{
return _item2;
}
}
}
public class MyItem
{
int _item3;
public MyItem item3
{
set
{
_item3 = value;
}
}
}
And then in the Main code:
MyClass item1;
item1.item2.item3 = 25;
Not quite sure ;)
Peter
Yes, this is correct. It does not need to be properties.
int n = 12345;
n.ToString().Length.ToString()[0].ToString().Length;
is perfectly legal.
--
Happy Coding!
Morten Wennevik [C# MVP]