我广泛使用了一个特定静态类的成员函数.每次调用它的方法时都指定类名看起来很讨厌......
I make extensive use of member functions of one specific static class. Specifying the class name every time I call it's methods looks nasty...
我可以在不指定类名 C# 的情况下将静态类作为命名空间来调用其方法吗?
Can I import a static class as a namespace to call its methods without specifying the class name C#?
如果你的意思是导入它使得它的方法是全局的,不.
If you mean import it such that it's methods are global, no.
不过,您可能想查看扩展方法.它们是静态方法,当它们的类的命名空间被导入时,它们会在它们的第一个参数的类型上显示为实例方法.在此处查看更多信息:http://msdn.microsoft.com/en-us/library/bb383977.aspx
You might want to look at extension methods though. They are static methods that, when their class's namespace is imported, show up as instance methods on the type of their first argument. See more here: http://msdn.microsoft.com/en-us/library/bb383977.aspx
这篇关于我可以将静态类作为命名空间导入以调用其方法,而无需在 C# 中指定类名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!