Can I do "using namespace.class"?

You cannot do that in any way in current C#. using just puts the namespace into your code so you don't have to explicitly write it each time you need it.

If your class is static and you are using C# 6.0, you can do this:

using static System.Console;

private static void Main(string[] args)
{
    WriteLine("test");
}

You can't for now. But in C# 6.0 you will be able able to use using directives for static classes.

For example:

using System.Console;
// ...
Write(4);

You can see the detailed list for all features here


As the other answers has already explained this won't be possible until C# 6. You can however make your life easier with aliases that allow you to create an custom name for a type. It's very handy for example when some class has a longer name or for whatever other reason:

You define an alias by assigning a type to a name in the using Directive. There are also few other things that you should know about it:

  • The scope of a using directive is limited to the file in which it appears.

  • Create a using alias to make it easier to qualify an identifier to a namespace or type. The right side of a using alias directive must always be a fully-qualified type regardless of the using directives that come before it.

  • Create a using directive to use the types in a namespace without having to specify the namespace. A using directive does not give you access to any namespaces that are nested in the namespace you specify.

using util = MyNameSpace.MyVeryLongNameStaticUtilityClass;
using other = MyNameSpace.MyVeryLongNameOtherClass;

Then you can use it like it was this type:

private static void Main(string[] args)
{
    var result = util.ParseArgs(args);
    var other = new other();
}