Home

Trying to figure out how-2 per new "using static"

Simple example stymies me on how to get it into LinqPad 5 error free.
It does not like the usings. Complains they must precede all other elements defined in the namespace.
I get that - but it seems I used to get prompted to add the usings.

Maybe a more succinct question would be - how can I play with this new functionality?

using static System.Console;
using static System.Math;
using static System.DayOfWeek;

void Main()
{
WriteLine(Sqrt(3*3 + 4*4));
WriteLine(Friday - Monday);
}

Comments

  • edited September 2015
    To reduce clutter, LINQPad has a separate place for putting 'using' directives. Press F4 and click 'Additional namespace imports'.

    In the box provided, enter this:
    static System.Console
    static System.Math
    static System.DayOfWeek
    Note that you don't need to prefix each line with the 'using' directive. LINQPad adds this for you automatically. If you're pasting code from another application, LINQPad will automatically strip out the redundant 'using' directives.

Sign In or Register to comment.