Well, there are two parts to this:
Are they calling the same Attribute
method?
Yes. There's only one XElement.Attribute
method, with an XName
parameter, which means that in the latter case you are using the implicit string to XName
conversion.
Does the implicit string to XName
conversion do the same as XName.Get
?
This isn't guaranteed - the documentation doesn't mention it. But I have no reason to doubt SLaks' analysis that the current implementation is the same.
Personally I always either use the conversion from string to XName
or the addition operator between XNamespace
and string to get an XName
. I can't remember the last time I referred to it explicitly.
The conversions available are one of the beautiful things about LINQ to XML - it seems pointless to ignore them, IMO.