如何导入/实现静态类的所有本机方法到自定义类? [英] How I could Import/Implement all the native methods of an static Class into a custom Class?
问题描述
我有这个类
导入_Console = System.Console
我的想法只是使用该类作为全部符合
Public Class ConsoleEx' Inherits _Console
公共共享子MyCustomMethod()
'做某事
结束子
结束类
控制台的替换 code> Class,那么我想能够使用 ALL
控制台
类方法正常,但从我的自定义ConsoleEx
类和我的自定义方法,例如:
ConsoleEx.WriteLine(Parametters)
'我的自定义方法:
ConsoleEx.MyCustomMethod(Parametters)
我不懒,但我想这可能是一步一步做到的?框架不提供任何东西吗?
这是最简单的方法吗?
解决方案(我知道这不是一个真正的答案,但我不能评论)
我认为你要找的是某种继承系统,但是控制台类不能继承。
所以我认为它不可能在一个简单的步骤
I have this Class
Imports _Console = System.Console Public Class ConsoleEx ' : Inherits _Console Public Shared Sub MyCustomMethod() ' Do something End Sub End Class
And my idea is just to use that Class as a FULL qualified replacement of the
Console
Class then I would like to be able to use ALL theConsole
class methods as normally but from my customConsoleEx
class together with my custom methods, for example:' Native Console class method: ConsoleEx.WriteLine(Parametters) ' My custom method: ConsoleEx.MyCustomMethod(Parametters)
I'm not lazy but I imagine that this could be possibly to do it in one step? Framework does not provide anything to do it?
Which is the easiest way to do it?
解决方案(i know this is not really an answer but i cannot comment yet)
I think what you are looking for is some sort of inheritance system but the Console class cannot be inherited. So i think its not possible to do in "one simple step"
这篇关于如何导入/实现静态类的所有本机方法到自定义类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!