944,174 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1686
  • C# RSS
May 19th, 2007
0

Re: How to solve ( Sort a queue )?

Expand Post »
hi
i want to know that if we are giving a namespace in C# what will be the impact
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sandipbhoyar is offline Offline
1 posts
since Mar 2007
May 19th, 2007
0

Re: Namespaces

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.
Reputation Points: 11
Solved Threads: 17
Junior Poster
mariocatch is offline Offline
103 posts
since Apr 2007
May 25th, 2007
0

Re: Namespaces

Namespaces just allow you to manage your code better.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
huenemeca is offline Offline
6 posts
since May 2007
May 27th, 2007
0

Re: Namespaces

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.
Reputation Points: 69
Solved Threads: 75
Posting Pro in Training
JerryShaw is offline Offline
465 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: data grid.... very urgent......
Next Thread in C# Forum Timeline: knight's tour problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC