PowerShell で扱える変数型備忘録
.NET Framework の CTS (Common Type System) で扱えると何処かでみた(ソース忘れた)ので、まずはそこから調べていたけど、PowerShell.com に判りやすい一覧表があった。
ついでなので、最大値と最小値も調べてみた。
| type | FullName | MinValue | MaxValue |
|---|---|---|---|
| [array] | System.Array | ||
| [bool] | System.Boolean | ||
| [byte] | System.Byte | 0 | 255 |
| [char] | System.Char | ||
| [datetime] | System.DateTime | 0001/01/01 0:00:00 | 9999/12/31 23:59:59 |
| [decimal] | System.Decimal | -79228162514264337593543950335 | 79228162514264337593543950335 |
| [double] | System.Double | -1.79769313486232E+308 | 1.79769313486232E+308 |
| [guid] | System.Guid | ||
| [hashtable] | System.Collections.Hashtable | ||
| [int16] | System.Int16 | -32768 | 32767 |
| [int32], [int] | System.Int32 | -2147483648 | 2147483647 |
| [int64], [long] | System.Int64 | -9223372036854775808 | 9223372036854775807 |
| [nullable] | System.Nullable | ||
| [psobject] | System.Management.Automation.PSObject | ||
| [regex] | System.Text.RegularExpressions.Regex | ||
| [sbyte] | System.SByte | -128 | 127 |
| [scriptblock] | System.Management.Automation.ScriptBlock | ||
| [single], [float] | System.Single | -3.402823E+38 | 3.402823E+38 |
| [string] | System.String | ||
| [switch] | System.Management.Automation.SwitchParameter | ||
| [timespan] | System.TimeSpan | -10675199.02:48:05.4775808 | 10675199.02:48:05.4775807 |
| [type] | System.Type | ||
| [uint16] | System.UInt16 | 0 | 65535 |
| [uint32] | System.UInt32 | 0 | 4294967295 |
| [uint64] | System.UInt64 | 0 | 18446744073709551615 |
| [xml] | System.Xml.XmlDocument |
Contents
調査のためのサンプルコード
$types = @([array], [bool], [byte], [char], [datetime], [decimal], [double], [guid], [hashtable], [int16], [int32], [int], [int64], [long], [nullable], [psobject], [regex], [sbyte], [scriptblock], [single], [float], [string], [switch], [timespan], [type], [uint16], [uint32], [uint64], [xml])
foreach($type in $types){
Write-Output ("| {0} | {1} | {2} | {3} |" -f $type.Name, $type.FullName, $type::MinValue, $type::MaxValue)
}
ディスカッション
コメント一覧
まだ、コメントがありません