IrishChieftain (2) [Avatar] Offline
#1
Just started reading this great book but am confused by the following syntax:

first.Name.CompareTo(second.Name);

It seems to be:

instance.property.method();

Normally, I see instance.method();

Am I missing something here?
jon.skeet (451) [Avatar] Offline
#2
Re: Interface Syntax in 1.4 and 1.5
No, it's just retrieving a property and then calling a method. You can chain that sort of thing as far as you like:

person.Father.Wife.Name.Length.ToString()

etc. It's normally not a good idea to go too far (look up the Law of Demeter) but in this case it makes sense - we're asking the name of one product to compare itself to the name of another product.

Jon
IrishChieftain (2) [Avatar] Offline
#3
Re: Interface Syntax in 1.4 and 1.5
Thanks Jon,

I'm getting rusty! I think this book and the Illustrated series by Daniel Solis are the best C# books I have seen out there.

Great work,
Anthony smilie
jon.skeet (451) [Avatar] Offline
#4
Re: Interface Syntax in 1.4 and 1.5
Thanks smilie I can't say I've read the Illustrated books... I'll keep an eye out for them.