0

Good programming habits questions. Do additional using statements that the Class does not use affect the speed of the application?

Example I have a Class called StoreController -

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

However, it only needs

using System.Web.Mvc; //Love some Resharerper

My question still, does it really affect the application to have the unused using statements?

Moojjoo
  • 729
  • 1
  • 12
  • 33
  • No, there is no performance impact. – T McKeown Jan 02 '14 at 15:53
  • 2
    Those are [using directives](http://msdn.microsoft.com/en-us/library/sf0df423.aspx). C# *has* a [using statement](http://msdn.microsoft.com/en-us/library/yh598w02.aspx) but it's something different. It helps, when there are two features that use the same keyword, to use the correct terminology. – Damien_The_Unbeliever Jan 02 '14 at 15:54
  • I think it might be helpful. http://stackoverflow.com/questions/12026820/do-unused-usings-in-net-affect-performance – Farhad Jabiyev Jan 02 '14 at 15:55

2 Answers2

2

There's no impact at runtime, however having a bunch of useless text in the screen bothers your fellow developers. Remove unused Usings, always.

Edit: using System.Linq; is to C# as air breathing is to humans. Leave it there always, even if it's not being used at present.

Federico Berasategui
  • 43,562
  • 11
  • 100
  • 154
1

Grant's comment is the correct. The using directives are used during compilation to determine the correct type references. They do not affect application execution.

jjrdk
  • 1,882
  • 15
  • 18