i want to know that if we are giving a namespace in C# what will be the impact

what will be the impact of what? a performance hit on the program?

pretty much none... you can consider namespaces containers for classes, which don't actually exist in memory in the current program unless you are specifcally "using" that namespace. and in any case, the impact of anything in C# really isn't that bad since C#'s garbage collector is doing all the work for you.

Namespaces just allow you to manage your code better.

Namespace declarations do not impact the resulting application.
They are used by the pre compiler to locate code addressing during the compile phase. You could preface every object and type in your source code with its namespace, and all you are doing is beating up yourself.

The c# compiler examines each object and type in your source code as it compiles. It searches the namespaces you have declared. IOW, declaring the Namespace's at the top of the code allows you to write code without prepending the correct namespace for each and every object and type.

If you need lets say the name of the PC, and did not add System.Net in your uses section, then doing it this way:
string MyPCname = System.Net.Dns.GetHostName();
would do the same thing as adding System.Net to the using section and just write string MyPCname = Dns.GetHostName(). Just because you add System.Net to the using section does not mean that every method in that name space is included in your compiled application. In either case, the compiler either searched your using section, or used your direct implementation to find the address of Dns.GetHostName().

Using the direct call (inluding the namespace) just saved the pre compiler a search step.... Not you. The resulting application performance is not affected using either method of declaration.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.