TOP >
lesson4
Lesson 4-3(変数)
変数
Alias=echo
変数の設定は以下。
$x="ABC"
変数[x]に文字列[ABC]をセットしています。
変数の型は自動判別です。
変数に入れる内容によって、勝手に作ってくれます。
型の確認は以下。
$x.GetType()
型を指定して変数を作成する場合、以下
[System.String] $x="ABC"
変数の指定の種類:
エイリアス | .NETの型名 |
byte | System.Byte |
int | System.Int32 |
long | System.Int64 |
single | float System.Single |
double | System.Double |
decimal | System.Decimal |
char | System.Char |
bool | System.Boolean |
string | System.String |
array | System.Array |
xml | System.Xml.XmlDocument |
type | System.Type |
参考:
http://www.atmarkit.co.jp/fwin2k/operation/psh02/psh02_02.html
配列変数1
カンマで区切る事により、変数が配列となる。
$x="ABC","DEF","GHI"
$x[0]〜$x[n…] となる。
配列変数2
連想配列の指定
$x = @{first="ABC";second="DEF";therd="GHI"}
$x.first、$x.second … となる。