国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PowerShell > 正文

Windows Powershell方法(對象能做什么)

2020-05-30 20:15:50
字體:
來源:轉載
供稿:網友

方法定義了一個對象可以做什么事情。當你把一個對象輸出在控制臺時,它的屬性可能會被轉換成可視的文本。但是它的方法卻不可見。列出一個對象的所有方法可是使用Get-Member命令,給“MemeberType”參數 傳入“Method”:

代碼如下:
PS C:Powershell> $Host | Get-Member -MemberType Method

   TypeName: System.Management.Automation.Internal.Host.InternalHost

Name                     MemberType Definition
----                     ---------- ----------
EnterNestedPrompt       Method     System.Void EnterNestedPrompt()
Equals                   Method     bool Equals(System.Object obj)
ExitNestedPrompt        Method     System.Void ExitNestedPrompt()
GetHashCode             Method     int GetHashCode()
GetType                  Method     type GetType()
NotifyBeginApplication  Method     System.Void NotifyBeginApplication()
NotifyEndApplication    Method     System.Void NotifyEndApplication()
PopRunspace             Method     System.Void PopRunspace()
PushRunspace            Method     System.Void PushRunspace(runspace runspace)
SetShouldExit            Method     System.Void SetShouldExit(int exitCode)
ToString                 Method     string ToString()

過濾內部方法

Get-Memeber列出了一個對象定義的所有方法,但并不是所有的方法都有用,有些方法的的用處非常有限。

Get_ 和 Set_ 方法

所有名稱以”get_”打頭的方法都是為了給對應的屬性返回一個值。例如”get_someInfo()”方法的作用就是返回屬性someInfo的值,因此可以直接通過屬性調用。

代碼如下:
PS C:Powershell> $Host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

PS C:Powershell> $Host.get_Version()

Major  Minor  Build  Revision

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荥经县| 北辰区| 睢宁县| 雷波县| 霍州市| 墨脱县| 蓬莱市| 包头市| 新郑市| 保定市| 阜宁县| 辰溪县| 凤冈县| 普兰县| 三都| 天等县| 大安市| 江西省| 冀州市| 西青区| 武鸣县| 阜阳市| 双江| 来宾市| 徐州市| 禄劝| 巩留县| 固镇县| 潮安县| 观塘区| 建昌县| 沅江市| 安多县| 西和县| 兰州市| 天长市| 沂南县| 清涧县| 隆德县| 安吉县| 平凉市|