#眉標=PowerShell #副標=PowerShell = Shell + Script + .NET(4) #大標=瞭解PowerShell的型別系統 #作者=文/蔡學鏞 ==<反灰>=========== PS > 2 + 3.0 + "4" 9 PS > 6/4 1.5 ================ ==<反灰>=========== PS > $a = @" >> Line one >> Line two >> Line three >> "@ >> PS > $a Line one Line two Line three ================ ==<反灰>=========== PS > $foo = "FOO" PS > "This is a string in double quotes: $foo" This is a string in double quotes: FOO ================ ==<反灰>=========== PS > "2+2 is $(2+2)" 2+2 is 4 ================ ==<反灰>=========== PS > "Expanding three statements in a string: $(1; 2; 3)" Expanding three statements in a string: 1 2 3 ================ ==<反灰>=========== PS > "Numbers 1 thru 10: $(for ($i=1; $i -le 10; $i++) { $i })."Numbers 1 thru 10: 1 2 3 4 5 6 7 8 9 10. ================ ==<反灰>=========== PS > $user = @{ FirstName = "John"; LastName = "Smith"; >> PhoneNumber = "555-1212" } PS > $user Key Value --- ----- LastName Smith FirstName John PhoneNumber 555-1212 ================ ==<反灰>=========== PS > $user.firstname John PS > $user.lastname Smith ================ ==<反灰>=========== PS > $user["firstname"] John PS > $user["firstname","lastname"] John Smith ================ ==<反灰>=========== PS > $user.keys LastName FirstName PhoneNumber ================ ==<反灰>=========== PS > $user.date = get-date PS > $user["city"] = "Seattle" PS > $user Key Value --- ----- city Seattle LastName Smith date 1/15/2006 12:01:10 PM FirstName John PhoneNumber 555-1212 ================ ==<反灰>=========== PS > $user.city = "Detroit" ================ ==<反灰>=========== PS > $user.remove("city") ================ ==<反灰>=========== PS > $a += 22,33 ================ ==<反灰>=========== PS > , 1 ================ ==<反灰>=========== PS > @() ================ ==<反灰>=========== PS > @(1) ================ ==<反灰>=========== $i = [int] "123" $i = [System.Int32] "123" ================ ==<反灰>=========== PS > [math]::Pi 3.14159265358979 PS > [math]::sin(22) -0.00885130929040388 ================ ==<反灰>=========== PS > [int] [char]"a" 97 ================