Diference between Using Namespace and Namespace.Class.Method in the code....
-
I had a dll referenced in my project having namespace Utilities. I can access the methods in the namespace by writing Using Utilities at the top of my project and directly I can use Utilities.Class.Method..... Plz let me know what the exact difference between these two ways. Thanks, Bhuvan....
-
I had a dll referenced in my project having namespace Utilities. I can access the methods in the namespace by writing Using Utilities at the top of my project and directly I can use Utilities.Class.Method..... Plz let me know what the exact difference between these two ways. Thanks, Bhuvan....
No difference at all. Except without using
Using
you have to writeNamespace.Class.Method
everywhere you want to use that method. Hope can help :) [Edit] Also it's worthy to searchUsing
in MSDN.I died as a mineral and became a plant, I died as plant and rose to animal, I died as animal and I was Man. Why should I fear? When was I less by dying? -- Rumi[^] My blog
modified on Thursday, December 4, 2008 2:43 AM
-
No difference at all. Except without using
Using
you have to writeNamespace.Class.Method
everywhere you want to use that method. Hope can help :) [Edit] Also it's worthy to searchUsing
in MSDN.I died as a mineral and became a plant, I died as plant and rose to animal, I died as animal and I was Man. Why should I fear? When was I less by dying? -- Rumi[^] My blog
modified on Thursday, December 4, 2008 2:43 AM
Yep....Thanks.... :)
-
No difference at all. Except without using
Using
you have to writeNamespace.Class.Method
everywhere you want to use that method. Hope can help :) [Edit] Also it's worthy to searchUsing
in MSDN.I died as a mineral and became a plant, I died as plant and rose to animal, I died as animal and I was Man. Why should I fear? When was I less by dying? -- Rumi[^] My blog
modified on Thursday, December 4, 2008 2:43 AM
Pedram Behroozi wrote:
No difference at all.
Not quite. By prefixing the class with the namespace you can avoid name clashes. If two (or more) usings have the same class, then you will get a compiler error if you don't specify the namespace. Likewise, if you forget to include your namespace via
using
and there's another namespace using your class name, then you might accidentally use this class. Sure, the signatures won't match, but it can give you some headache because you might not know what the compiler is complaining about. regards