472,353 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Having "using" when not necessary, performance hit?

a
Is there a performance hit if I have many "using" statements that are
unnecessary? For example:

using System.Collections;

when nowhere in my code I'm using System.Collections namespace.

I'm really thinking about the default "using" statements put by VS.NET.
Nov 15 '05 #1
5 2861
Hi,
The using directives don't affect the code generated. They used only to
simplify coding and create "shortcuts" to recently used types for C#
compiler (for example: you will write ArrayList instead of
System.Collections.ArrayList, and compiler will know that, it this context,
the ArrayList is System.Collections.ArrayList).
--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"a" <a@a.com> wrote in message news:eg**************@TK2MSFTNGP09.phx.gbl...
Is there a performance hit if I have many "using" statements that are
unnecessary? For example:

using System.Collections;

when nowhere in my code I'm using System.Collections namespace.

I'm really thinking about the default "using" statements put by VS.NET.

Nov 15 '05 #2
a <a@a.com> wrote:
Is there a performance hit if I have many "using" statements that are
unnecessary? For example:

using System.Collections;

when nowhere in my code I'm using System.Collections namespace.

I'm really thinking about the default "using" statements put by VS.NET.


There's no (runtime) performance hit because the compiled binary should
be the same. Compilation may take a tiny bit longer, but not
noticeably. Consider removing them anyway for the sake of readability
though. (Oh for Eclipse and its "Organize Imports" feature...)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3

Hi ,

The using statement does not generate redundant code in the exe file.
Also, it will not generate redundant metadata in manifest.(You can check
this through iLdasm.exe)
The using statement just expose certain dll's metadata information to your
application, so that the compiler can recognize the class and members.
Also, the compiler can generate intellisence for you.

I think you can make sure the "no generate redundant code" by checking the
file size between many "using" file and remove "using" file.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "a" <a@a.com>
| Subject: Having "using" when not necessary, performance hit?
| Date: Wed, 29 Oct 2003 23:31:44 -0800
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <eg**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: d206-116-117-170.bchsia.telus.net 206.116.117.170
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:195287
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Is there a performance hit if I have many "using" statements that are
| unnecessary? For example:
|
| using System.Collections;
|
| when nowhere in my code I'm using System.Collections namespace.
|
| I'm really thinking about the default "using" statements put by VS.NET.
|
|
|

Nov 15 '05 #4
Actually I think the respective assemblies will only be loaded at the time
your code accesses them.

Scarfeet

"a" <a@a.com> schrieb im Newsbeitrag
news:eg**************@TK2MSFTNGP09.phx.gbl...
Is there a performance hit if I have many "using" statements that are
unnecessary? For example:

using System.Collections;

when nowhere in my code I'm using System.Collections namespace.

I'm really thinking about the default "using" statements put by VS.NET.

Nov 15 '05 #5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wonder if this will be a feature in the next VS.NET. I'll second a
feature request like this with all my heart :)

Jon Skeet [C# MVP] wrote:

| though. (Oh for Eclipse and its "Organize Imports" feature...)

- --
Ray Hsieh (Ray Djajadinata) [SCJP, SCWCD]
ray underscore usenet at yahoo dot com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQE/oPLewEwccQ4rWPgRAlCpAJ9w2lI0cNRZ9wbSDNAffYAEbKMiNw CffbsW
UOSwKswMhRsUyaXYDKXAKgM=
=s5MI
-----END PGP SIGNATURE-----

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Giles Brown | last post by:
I'm feeling quite dumb this morning. I'm trying to build a COM server DLL using py2exe and it ain't working. Here's what ain't working... ...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the...
5
by: charliewest | last post by:
I've implemented the USING statement to ensure that my newly created sql connection closes when my method is finished using it. The USING statement...
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other...
43
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \...
6
by: OriginalBrownster | last post by:
Hi there... I'm still pretty new to turbogears. but i have gotten pretty familiar with it i'm just trying to clear something up, i'm having a...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the...
25
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be...
0
by: Joe Strout | last post by:
Hi Luis, A static variable IS encapsulation. Encapsulation happens at many levels: module, class, instance, and (in languages that support it)...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.