logo
  • 教程列表
  • SO官方文档
  • PowerShell 类
    • 列出类的可用构造函数
    • 方法和属性
    • 构造函数重载
    • 获取实例的所有成员
    • 基本类模板
    • 从父类到子类的继承
  1. StackOverflow 文档
  2. PowerShell 教程
  3. PowerShell 类
  4. 从父类到子类的继承

从父类到子类的继承

Created: November-22, 2018

class ParentClass
{
    [string] $Message = "Its under the Parent Class"

    [string] GetMessage()
    {
        return ("Message: {0}" -f $this.Message)
    }
}

# Bar extends Foo and inherits its members
class ChildClass : ParentClass
{

}
$Inherit = [ChildClass]::new()

SO, $ Inherit.Message 会给你

它属于父类

  • 基本类模板

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明