Guest User

Guest User

  • Tech Writer
  • 357
  • 120.7k

Accessing a property then a method

Jul 12 2012 10:47 AM
Hi

Ive seen it time and time again whereby an instance property member of a class is accessed followed by an instance method, all of the same line.

For example given this source code:-

var doc = XDocument.Load("aUrlReferencingaXMLDoc");

foreach(var item in doc.Root.Elements())

What I would like to know is how is this possible to access the Elements method straight from the Root property? is is because they both have the same Return type, in this case XElement?

Regards

Steven



Answers (5)