static imports in c#

后端 未结 4 723
南方客
南方客 2020-12-15 15:22

Does C# has feature like Java\'s static imports?

so instead of writing code like

FileHelper.ExtractSimpleFileName(file)

I could wr

4条回答
  •  不知归路
    2020-12-15 15:27

    No, such feature doesn't exist in C#. You need to specify the class that the static method belongs to unless you are already inside a method of this same class.

    In C# though you have extension methods which kind of mimic this.

提交回复
热议问题