Can I remove all the use I'm not using?

17

I took a project here ASP.NET C # and I realize I can pull several "using".

Can I exit by removing these using or not?

Does using that is not used in class can be used by someone who is using class ? No, right?

    
asked by anonymous 12.01.2017 / 14:10

3 answers

19

Yes you can. The using directive (not to be confused with the using command used to free resources) is just a way to avoid very large digits.

Visual Studio and well indicates what can be removed without fear.

All types have namespaces , meaning surnames for them. To use only name and not last name we use using , so all types contained in the namespace is available in that code by its name from where using is used.

If you do not use a namespace name, it is not required. Not only does it not cause problems, withdrawal can avoid problems by letting you use something unwittingly that is available because you left something unnecessary there. You use it thinking it's one thing, but it's another. It's not serious, you'll probably notice the error soon, but it gets in the way.

From C # 6 you can use using for static classes as well.

I talked about it in Using unused affect performance? .

    
12.01.2017 / 14:33
16

Right-click (in the code window), go to the > Organize Usings > Remove Unnecessary Using.

You will not have any problems with your code, so you can add them again.

Some related posts

    
12.01.2017 / 14:17
9

It's okay to remove them (the ones that are not being used usually get a less prominent tone), a good alternative to make this and other actions less workable is the free tool Productivity Power Tools

Every time you save, the tool automatically removes Unnecessary Using

    
12.01.2017 / 15:59