Inheritance from Parent Class to Child Class

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

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

# ChildClass inherits ParentClass members. Classes require PowerShell 5.0 or later.
class ChildClass : ParentClass
{

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

So $Inherit.Message returns

“Its under the Parent Class”

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents