Using References

  • Thread starter Thread starter TheLostLeaf
  • Start date Start date
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.
 
No, it's just a way of writing shorter code

List x

instead of

System.Collections.List x



Pete
 
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.
 
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.
 
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.
 
Back
Top