c# – How to use a static class

Question:

There is a static Helper class. I want to use it from another form, but I have to call it through Helper.Val . Is it possible to do something like using Helper; and then just call Helper

public static class Helper
{
    public static double Val(string data)
    {
        return Convert.ToDouble(data.Replace(".", ","));
    }
}

Answer:

Here's how.

At the beginning of the file

using static YourNamespace.Helper;

and in the code just

double v = Val(data);

(Note, not just using , but using static .)

Works since C # 6 (Visual Studio 2015).

Scroll to Top