logo
  • 教程列表
  • SO官方文檔
  • PowerShell 類
    • 列出類的可用建構函式
    • 方法和屬性
    • 建構函式過載
    • 獲取例項的所有成員
    • 基本類别範本
    • 從父類到子類的繼承
  1. StackOverflow 文件
  2. PowerShell 教程
  3. PowerShell 類
  4. 方法和屬性

方法和屬性

Created: November-22, 2018

class Person {
    [string] $FirstName
    [string] $LastName
    [string] Greeting() {
        return "Greetings, {0} {1}!" -f $this.FirstName, $this.LastName
    }
}

$x = [Person]::new()
$x.FirstName = "Jane"
$x.LastName = "Doe"
$greeting = $x.Greeting() # "Greetings, Jane Doe!"
  • 建構函式過載
  • 列出類的可用建構函式

Copyright © 2018. All right reserved

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

  • 關於本站
  • 免責聲明