Is “static class imports” actually an announced or hinted at future feature of C#? [closed]

StackOverflow https://stackoverflow.com/questions/11010125

  •  14-06-2021
  •  | 
  •  

Question

Starting from this edit, the Wikipedia article on C# mentions "static class imports" as a future feature of C#, alongside "Compiler-as-a-service ("Roslyn")".

Has this feature actually been announced or hinted at by a member of the compiler team or is this just wild speculation?

Was it helpful?

Solution

In the Eric Lippert's article that's most likely the source of this, he's discussing using C# as a scripting language. And, the Roslyn CTP includes C# Interactive window and a C# scripting engine.

C# Interactive uses a somewhat different version of C#. For example, you don't always need semicolons, and you can have top-level methods and top-level statements. And you can also use static class imports:

> using System.Math;
> Abs(-5)
5

Because of this, I think static class imports (along with the other “scripty” features I mentioned) won't be included in the normal version of C#, but you will be able to use them in C# scripts.

OTHER TIPS

Eric Lippert made a post about this feature but he didn't promise an implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top