I make extensive use of member functions of one specific static class. Specifying the class name every time I call it's methods looks nasty...
Can I import a static class as a namespace to call its methods without specifying the class name C#?
I make extensive use of member functions of one specific static class. Specifying the class name every time I call it's methods looks nasty...
Can I import a static class as a namespace to call its methods without specifying the class name C#?
Yes, you can. C# 6 introduced new construct - the using static directive lets you import all the static members of a type, so that you can use those members unqualified :
using static ClassName;
for instance:
using System;
using static System.Console;
class Program
{
static void Main()
{
WriteLine("test");
}
}