Is there any difference between doing this…
using System.Xml.Linq;
XDocument xml = XDocument.Parse(page);
or this…
System.Xml.Linq.XDocument xml = XDocument.Parse(page);
Other than the first one makes everything easier to write and cleaner code?
edit: I only used Linq as an example, I’m asking this for everything using/system/etc.. related.
There is absolutely no difference in terms of emitted IL. But in the second case you are writing more code which IMHO is not necessary especially when you want to declare multiple
XDocumentinstances in the same class. It’s simply useless to be that much explicit when declaring a variable type. Actually an even shorter way would be:It’s even easier with Shift+Alt+F10+Enter because in this case you only write:
and Visual Studio automatically adds the proper
usingafter putting the cursor overXDocument.