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

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

  •  14-06-2021
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top