How to “import” a static class in C#?

后端 未结 9 1368
挽巷
挽巷 2020-12-28 19:08

I have created a public static class utils.cs I want to use it in other classes without prefixing method with utils, what\'s the syntax to do this ?

9条回答
  •  孤城傲影
    2020-12-28 19:27

    I'm not sure what you're trying to accomplish by omitting the Utils prefix from the method calls. But if it's just to save space or make the code a little easier to read, you could alias the import to a shorter name:

    using U = Utils;
    

提交回复
热议问题