Why isn't 'using System' sufficient to write all the programs in c#? Why do i need to add different namespaces according to my requirement? For example if i want to use xmlelement I need to use system.xml namespace. Isn't system.xml a part of system namespace? If yes, then why do I need to mention 'using System.xml' along with 'using System;?
c#
Hi
VulpesPosted Sep 16, 2013, 11:59 AM
However, for the purposes of C#'s 'using' directive, each namespace is treated separately. So, if you want to use a class in the System.Xml namespace (XmlDocument say) without having to 'fully qualify' its name, then you must use:
using System.Xml;
You might reasonably have thought that if you did this:
using System;
then you'd be able to do this:
Xml.XmlDocument doc = new Xml.Document();
but, if you try to do that, you'll get a compiler error.
Curiously, though, you can do this sort of thing in VB.NET which is a much more forgiving language than C#. For example the following compiles fine:
vidyaPosted Sep 26, 2013, 1:03 AM
Jignesh TrivediPosted Sep 16, 2013, 2:43 AM
system and system.xml both are different namespace. it might possible different namespace with in different assembly or two namespace contain same class.
hope this will help you.
Pavan RamamurthyPosted Sep 16, 2013, 1:54 AM
Suthish NairPosted Sep 15, 2013, 3:43 PM