Namespaces

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2007
Posts: 1
Reputation: sandipbhoyar is an unknown quantity at this point 
Solved Threads: 0
sandipbhoyar's Avatar
sandipbhoyar sandipbhoyar is offline Offline
Newbie Poster

Re: How to solve ( Sort a queue )?

 
0
  #1
May 19th, 2007
hi
i want to know that if we are giving a namespace in C# what will be the impact
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 103
Reputation: mariocatch is an unknown quantity at this point 
Solved Threads: 17
mariocatch mariocatch is offline Offline
Junior Poster

Re: Namespaces

 
0
  #2
May 19th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 6
Reputation: huenemeca is an unknown quantity at this point 
Solved Threads: 0
huenemeca huenemeca is offline Offline
Newbie Poster

Re: Namespaces

 
0
  #3
May 25th, 2007
Namespaces just allow you to manage your code better.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: Namespaces

 
0
  #4
May 27th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC