问题描述
我广泛使用了一个特定静态类的成员函数.每次调用它的方法时都指定类名看起来很讨厌......
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# 中指定类名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)