Using References

T

TheLostLeaf

Heres a noob question. Does it waste system resources if you include
using statements at the top of the code page, but your code never uses
them ? For example should you go through every .cs file and remove any
references that are not being used ?

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

Thanks.
 
P

Peter Morris

No, it's just a way of writing shorter code

List x

instead of

System.Collections.List x



Pete
 
N

Nicholas Paldino [.NET/C# MVP]

TheLostLeaf,

No, not at all.

The using statement just allows you to use short name for a type when
using it in your code. Types in the namespace in the "using" statement
don't need to have the full namespace syntax.

It should be noted that using statements are NOT references. It's
simply a way of allowing you to use the short type name instead of the
namespace-qualified type name.
 
J

Jon Skeet [C# MVP]

Nicholas Paldino said:
No, not at all.

The using statement just allows you to use short name for a type when
using it in your code. Types in the namespace in the "using" statement
don't need to have the full namespace syntax.

It should be noted that using statements are NOT references. It's
simply a way of allowing you to use the short type name instead of the
namespace-qualified type name.

Just as a further point of pedantry, those are using directives, not
using statements. Using statements are the ones which call Dispose
automatically :)

On everything else, I agree with Nicholas entirely.
 
B

Ben Voigt [C++ MVP]

TheLostLeaf said:
Heres a noob question. Does it waste system resources if you include
using statements at the top of the code page, but your code never uses

The compiler will use extra resources and possibly take longer (probably not
measurably), the application it creates won't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top