When I am using an XElement once, should I declare it inline e.g.
user.name = new XElement("Name", "John Doe");
or declare the XElement on its own line, e.g.
XElement elem = new XElement("Name", "John Doe");
user.name = elem;
When I am using an XElement once, should I declare it inline e.g.
user.name = new XElement("Name", "John Doe");
or declare the XElement on its own line, e.g.
XElement elem = new XElement("Name", "John Doe");
user.name = elem;
Use whatever you like. The compiler will optimize it to the same thing anyway.
user.name = new XElement("Name", "John Doe");
is fine if you are only going to use it once. saves a few bytes for the extra pointer.
I think the fact that you don't have a meaningful name ("elem") for the XElement variable is telling. The XElement only has meaning assigned to name, so I'd do it inline.