Windows Powershell 創(chuàng)建數(shù)組
在Powershell中創(chuàng)建數(shù)組可以使用逗號。
PS C:Powershell> $nums=2,0,1,2 PS C:Powershell> $nums 2 0 1 2
對于連續(xù)的數(shù)字數(shù)組可以使用一個更快捷的方法
PS C:Powershell> $nums=1..5 PS C:Powershell> $nums 1 2 3 4 5
數(shù)組的多態(tài)
象變量一樣如果數(shù)組中元素的類型為弱類型,默認可以存儲不同類型的值。
PS C:Powershell> $array=1,"2012世界末日",([System.Guid]::NewGuid()),(get-date) PS C:Powershell> $array 1 2012世界末日 Guid ---- 06a88783-a181-4511-9e41-2780ecbd7924 DisplayHint : DateTime Date : 2011/12/9 0:00:00 Day : 9 DayOfWeek : Friday DayOfYear : 343 Hour : 14 Kind : Local Millisecond : 910 Minute : 15 Month : 12 Second : 45 Ticks : 634590369459101334 TimeOfDay : 14:15:45.9101334 Year : 2011 DateTime : 2011年12月9日 14:15:45
空數(shù)組和單元素數(shù)組
空數(shù)組
PS C:Powershell> $a=@() PS C:Powershell> $a -is [array] True PS C:Powershell> $a.Count 0
1個元素的數(shù)組
PS C:Powershell> $a=,"moss" PS C:Powershell> $a -is [array] True PS C:Powershell> $a.Count 1
相關(guān)文章
Windows Powershell調(diào)用靜態(tài)方法
Powershell將信息存儲在對象中,每個對象都會有一個具體的類型,簡單的文本會以System.String類型存儲,日期會以System.DateTime類型存儲。任何.NET對象都可以通過GetType()方法返回它的類型,該類型中有一個FullName屬性,可以查看類型的完整名稱。2014-09-09PowerShell中使用Filter來創(chuàng)建管道輸入函數(shù)
這篇文章主要介紹了PowerShell中使用Filter來創(chuàng)建管道輸入函數(shù),Filter創(chuàng)建的函數(shù)跟Function創(chuàng)建的函數(shù),在本質(zhì)上是一樣的,需要的朋友可以參考下2014-07-07PowerShell中使用return語句退出函數(shù)例子
這篇文章主要介紹了PowerShell中使用return語句退出函數(shù)例子,return語句在編程語言中一般都有退出函數(shù)的功能,需要的朋友可以參考下2014-07-07PowerShell函數(shù)中使用必選參數(shù)實例
這篇文章主要介紹了PowerShell函數(shù)中使用必選參數(shù)實例,即把一個參數(shù)設(shè)置為必選參數(shù)的方法,需要的朋友可以參考下2014-07-07PowerShell中使用Like運算符配合通配符查找字符串例子
這篇文章主要介紹了PowerShell中使用Like運算符配合通配符查找字符串例子,Like的返值為TRUE和FALSE,需要的朋友可以參考下2014-08-08PowerShell定義函數(shù)參數(shù)的2種方法和傳參方法實例
這篇文章主要介紹了PowerShell定義函數(shù)參數(shù)的2種方法和使用方法實例,簡潔易懂的好文,需要的朋友可以參考下2014-07-07