Difference between "using" directive and adding reference in solution explorer in visual studio?
What is the difference between "using" directive and adding reference in solution explorer in visual studio? Can somebody explain it in more details? Can somebody explain it in more details?

VulpesPosted Jul 28, 2012, 1:26 PM
So, if you have this in your file:
using System.Windows.Forms;
then you can use class names such as Form, TextBox, ListBox etc without having to qualify them with the namespace they're in.
In other words, if you didn't have the using directive, then you'd have to write stuff like this:
System.Windows.Forms.MessageBox.Show("Hello");
rather than simply this:
The 'using' directive is therefore just a device to save typing and to make your code easier to read.
In contrast, when you add a reference in Solution Explorer, then you're adding a reference to a .NET class library (i.e. a dll) to your project. What this means is that the compiler imports information about the public types within the dll into your project so that you can use those types as if they were part of your project itself.
Usually, those types are defined within namespaces and so it is worthwhile to include 'using' directives for those namespaces within your project so that you don't have to 'fully qualify' them as described earlier in this post.