Cybertof <cy****************@gmx.net> wrote in
news:MP************************@msnews.microsoft.c om:
What is the difference between :
- adding a new reference to a namespace within the SolutionExplorer
(right click, Add Reference...)
- adding a new reference with the 'using' keyword in the source code
For example, System.Windows.Forms is both in the SolutionExplorer and
in the using statement, some other namespaces are only inside the
code.
They are indeed two different things.
First, when you 'Add Reference...' you aren't really doing anything with
namespaces, per se. You are adding a reference to a DLL which contains
one or more namespaces, each containing one or more objects (classes,
enums, structs, etc...)
In order to make things easier on you and the IDE, the IDE/compiler
wants to know what namespaces it should search in when you type
something like
Form x = new Form()
Form is actually in the System.Windows.Forms namespace, inside the
System.Windows.Forms.DLL file (the fact that they are named the same is
for convenience - there are other namespaces available in this same
DLL). If you didn't have the line "using System.Windows.Forms" at the
top of your file, you would have to explicitly say
System.Windows.Forms.Form x = new System.Windows.Forms.Form()
If you are curious and want to see what namespaces are in any particular
'Add Reference...' item, open the 'References' group in the Solution
Explorer and double click one of them (or right-click and select 'View
in Object Browser'). Anything with a pair of braces ("{}") is a
namespace that you can reference with a "using..." line.
-mbray