The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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 (483) [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 (483) [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.