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

  • 關於本站
  • 免責聲明