【发布时间】:2023-01-04 02:28:14
【问题描述】:
我想从其覆盖函数调用父函数,我在以下代码中隔离了我的问题:
class SomeClass{
[type]GetType(){
write-host 'hooked'
return $BaseClass.GetType() # how do i call the BaseClass GetType function??
}
}
SomeClass::new().GetType()
我期待这样的输出:
hooked
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True SomeClass System.Object
【问题讨论】:
-
Object.GetType()是非虚拟的并且不能被覆盖(尽管您可以通过多种方式隐藏它)。你到底想完成什么?
标签: powershell oop overriding base-class