| int | 有符號,32bit |
| long | 有符號,64bit |
| double | 雙精度64bit浮點 |
| single | 單精度32bit浮點 |
| string | unicode編碼字符串 |
| char | unicode編碼字符,16bit |
| byte | 無符號字符,8bit |
| decimal | 十進(jìn)制數(shù),128bit |
| array | 數(shù)組 |
| xml | xml對象 |
| hashtable | 哈希表 |
| bool | true、false |
我們通過幾個例子來明白數(shù)據(jù)類型的意義。首先看看string的例子:
$strA = “Hello “ enter>
$strB = “World!” enter>
$strC = $strA + $strB enter>
$strC enter>

對字符串的操作還有其他方法,如:
替換
$strA = “hi! world!” enter>
$strB = $strA -replace “hi!”, “Hello” enter>
$strB enter>

引用
看看下面的例子:
$strA = “MaRui” enter>
"This is $strA.” enter>
'This is $strA.' enter>

在PowerShell中,對數(shù)字進(jìn)行運(yùn)算操作十分簡單,不需要過多說明,只用幾個例子:
5 + 100 enter>
$x=200+1 enter>
$x enter>
[int]$y=(7 + 13 * 2) / 10 enter>
$y enter>

有時,PowerShell并不能很好的為我們自動指定數(shù)據(jù)類型,因此,在編寫腳本時,請盡可能的為變量聲明數(shù)據(jù)類型,以防出錯。在數(shù)學(xué)運(yùn)算上,有如下操作:
| + | 加 |
| - | 減 |
| * | 乘 |
| / | 除 |
| % | 取余 |
| = | 賦值 |
| ++ | 給變量加1,相當(dāng)于+1 |
| -- | 給變量減1,相當(dāng)于-1 |
當(dāng)然,括號也是免不了要用的。
標(biāo)簽:黔南 河北 通遼 隴南 河池 淮南 常州 黔南
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《探索PowerShell(七) PowerShell變量》,本文關(guān)鍵詞 探索,PowerShell,七,變量,探索,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。