How can global function exist in C#?

前端 未结 7 1568
暖寄归人
暖寄归人 2020-12-29 05:58

How can global function exist in C# when everything is defined inside a class? I was reading the documentation of OpCodes.Call at MSDN, and was surprised to see the followin

7条回答
  •  滥情空心
    2020-12-29 06:31

    At the Build 2014 conference it was announced that from Roslyn onwards, you can import static methods from types by the using TypeName; directive, so that instead of having to use System.Math.Min(...) you can do:

    using System.Math;
    ...
    var z = Min(x,y);
    

    Note: by the time of release this became:

    using static System.Math;
    

提交回复
热议问题