Looking at a few solutions of programming challenges on CodeAbbey, I've noticed many C# solutions implementing the following at the beginning of the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Aside from System
, it appears the statements are not used. They are even implemented for simple looping programs. Ideone examples: 1 2 3
Are these statements in fact needed for the code to function, or are they added as a matter of habit?
If in Visual Studio 2013, with a .NET 4.5 project, you Add New Item, Class, you get this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace (yournamespace)
{
class Class1
{
}
}
that includes those using
. If you don't need them, you can remove them (or you can more easily right click, Organize Usings, Remove Unused Usings)
If you then discover that you need them, it is quite easy to right-click on an error, Resolve, using (something).
Note that there is an exception: extension methods. You can't "automagically" Resolve, using (something) with extension methods. For this reason, removing the using System.Linq
can be a pain, because then if you use LINQ you have to re-add it "manually" (by typing using System.Linq
).