473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 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 2928
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... setup_dll.py based on py2exe sample: """from...
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 difference of one statement in the WHERE clause. If I...
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 is wrapped in try/catch error handling 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 issues i've noticed that for localy created objects...
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) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \...
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 difficult time using \ when declaring a string...
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 following error:
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 declared as governing the following statements. For...
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) method. A static local variable is simply the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.