C# 6.0 New Features - Using statements for static classes
Currently using statements are for namespaces only. With this new feature they can used for static classes as well. Like this:
using System.IO;
using System.IO.File;
namespace CSharp6Features
{
class UsingStaticClass
{
public class StaticUsing
{
public StaticUsing()
{
File.WriteAllText("C:\test.txt", "test");
WriteAllText("C:\test.txt", "test");
}
}
}
}
I don’t think I liked this new feature. If you see a direct method call it feels like it’s a member of that method. But now it’s possible that method can be defined inside a static class somewhere else. I think it would just cause confusion and doesn’t add any benefit.