Powershell中可以使用的.Net实用静态方法
支持所有版本。
Powershell能够使用.net静态方法,比如下面有一些你常用的方法:
[Math]::Round(7.9) [Convert]::ToString(576255753217,8) [Guid]::NewGuid() [Net.Dns]::GetHostByName('schulung12') [IO.Path]::GetExtension('c:\test.txt') [IO.Path]::ChangeExtension('c:\test.txt','bak')
要获得更多的方法,你可以删掉方括号后面的代码,再添加两个冒号,这时在Powershell_ISE中将会弹出这个类所有可选的方法及属性。在Powershell控制台中,你也可以使用TAB来获取选择方法属性。
当然你也可以通过管道符查看他所有类型:
PS>[Math]|Get-Member-MemberType*Method-Static
TypeName:System.Math
Name MemberTypeDefinition ---- -------------------- Abs Method staticsbyteAbs(sbytevalue),staticint16Abs(int16value),staticintAbs(intvalue),sta... Acos Method staticdoubleAcos(doubled) Asin Method staticdoubleAsin(doubled) Atan Method staticdoubleAtan(doubled) Atan2 Method staticdoubleAtan2(doubley,doublex) BigMul Method staticlongBigMul(inta,intb) Ceiling Method staticdecimalCeiling(decimald),staticdoubleCeiling(doublea) Cos Method staticdoubleCos(doubled) Cosh Method staticdoubleCosh(doublevalue DivRem Method staticintDivRem(inta,intb,[ref]intresult),staticlongDivRem(longa,longb,[ref]... Equals Method staticboolEquals(System.ObjectobjA,System.ObjectobjB) Exp Method staticdoubleExp(doubled) Floor Method staticdecimalFloor(decimald),staticdoubleFloor(doubled) IEEERemainder Method staticdoubleIEEERemainder(doublex,doubley) Log Method staticdoubleLog(doubled),staticdoubleLog(doublea,doublenewBase) Log10 Method staticdoubleLog10(doubled) Max Method staticsbyteMax(sbyteval1,sbyteval2),staticbyteMax(byteval1,byteval2),staticint1... Min Method staticsbyteMin(sbyteval1,sbyteval2),staticbyteMin(byteval1,byteval2),staticint1... Pow Method staticdoublePow(doublex,doubley) ReferenceEqualsMethod staticboolReferenceEquals(System.ObjectobjA,System.ObjectobjB) Round Method staticdoubleRound(doublea),staticdoubleRound(doublevalue,intdigits),staticdouble... Sign Method staticintSign(sbytevalue),staticintSign(int16value),staticintSign(intvalue),stat... Sin Method staticdoubleSin(doublea) Sinh Method staticdoubleSinh(doublevalue) Sqrt Method staticdoubleSqrt(doubled) Tan Method staticdoubleTan(doublea) Tanh Method staticdoubleTanh(doublevalue) Truncate Method staticdecimalTruncate(decimald),staticdoubleTruncate(doubled)