Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the benefit of removing redundant imports in VB.net or using in C# file

Tags:

.net

resharper

I have been using ReSharper for quite a long time and get used to solve a lot of problems by typing Alt+Enter. One of my colleague asked me about the real benefits and I couldn't say a word apart from that if you are not using it why import it.

Can someone explain what are the real benefits of removing redundant imports if there are eany?

like image 923
Ybbest Avatar asked Jan 05 '10 22:01

Ybbest


2 Answers

Beside the fact that it cleans up your code, you can also minimize 'name clashes'.
For instance, when you have 2 types with the same name in different namespaces, and you do not use any type from one namespace ... You then do not have to specify the namespace of the type when using it, it keeps your code cleaner.

like image 191
Frederik Gheysels Avatar answered Nov 15 '22 10:11

Frederik Gheysels


It removes redundancy, which is a good thing. And its easy to get most of the needed using directives back, by pressing ALT+ENTER (with R#) or invoking the smart-tag by pressing CTRL+. (without R#) on the class that needs it.

On the negative side, you might lose sight of available extension methods, especially when the System.Linq namespace import is removed.

like image 40
Arjan Einbu Avatar answered Nov 15 '22 09:11

Arjan Einbu