Powershell中可以使用的.Net實(shí)用靜態(tài)方法
支持所有版本。
Powershell能夠使用.net靜態(tài)方法,比如下面有一些你常用的方法:
[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')
要獲得更多的方法,你可以刪掉方括號(hào)后面的代碼,再添加兩個(gè)冒號(hào),這時(shí)在Powershell_ISE中將會(huì)彈出這個(gè)類所有可選的方法及屬性。在Powershell控制臺(tái)中,你也可以使用TAB來(lái)獲取選擇方法屬性。
當(dāng)然你也可以通過(guò)管道符查看他所有類型:
PS> [Math] | Get-Member -MemberType *Method -Static
TypeName: System.Math
Name MemberType Definition
---- ---------- ----------
Abs Method static sbyte Abs(sbyte value), static int16 Abs(int16 value), static int Abs(int value), sta...
Acos Method static double Acos(double d)
Asin Method static double Asin(double d)
Atan Method static double Atan(double d)
Atan2 Method static double Atan2(double y, double x)
BigMul Method static long BigMul(int a, int b)
Ceiling Method static decimal Ceiling(decimal d), static double Ceiling(double a)
Cos Method static double Cos(double d)
Cosh Method static double Cosh(double value
DivRem Method static int DivRem(int a, int b, [ref] int result), static long DivRem(long a, long b, [ref] ...
Equals Method static bool Equals(System.Object objA, System.Object objB)
Exp Method static double Exp(double d)
Floor Method static decimal Floor(decimal d), static double Floor(double d)
IEEERemainder Method static double IEEERemainder(double x, double y)
Log Method static double Log(double d), static double Log(double a, double newBase)
Log10 Method static double Log10(double d)
Max Method static sbyte Max(sbyte val1, sbyte val2), static byte Max(byte val1, byte val2), static int1...
Min Method static sbyte Min(sbyte val1, sbyte val2), static byte Min(byte val1, byte val2), static int1...
Pow Method static double Pow(double x, double y)
ReferenceEquals Method static bool ReferenceEquals(System.Object objA, System.Object objB)
Round Method static double Round(double a), static double Round(double value, int digits), static double ...
Sign Method static int Sign(sbyte value), static int Sign(int16 value), static int Sign(int value), stat...
Sin Method static double Sin(double a)
Sinh Method static double Sinh(double value)
Sqrt Method static double Sqrt(double d)
Tan Method static double Tan(double a)
Tanh Method static double Tanh(double value)
Truncate Method static decimal Truncate(decimal d), static double Truncate(double d)
要查看方法的參數(shù),省略掉他的括號(hào)即可:
PS> Get-Something -Path test
You entered test.
PS> [Math]::Round
OverloadDefinitions
-------------------
static double Round(double a
static double Round(double value, int digits)
static double Round(double value, System.MidpointRounding mode)
static double Round(double value, int digits, System.MidpointRounding mode
static decimal Round(decimal d
static decimal Round(decimal d, int decimals)
static decimal Round(decimal d, System.MidpointRounding mode)
static decimal Round(decimal d, int decimals, System.MidpointRounding mode)
- 使用PowerShell .Net獲取電腦中的UUID
- PowerShell中使用.NET將程序集加入全局程序集緩存
- PowerShell入門(mén)教程之訪問(wèn).Net程序集、COM和WMI實(shí)例
- Powershell小技巧之查看安裝的.Net framework版本信息
- PowerShell中調(diào)用.NET對(duì)象的靜態(tài)方法、靜態(tài)屬性和類方法、類屬性例子
- PowerShell中查看當(dāng)前版本、Windows版本、.NET版本信息的代碼
- 一個(gè)ASP.Net下的WebShell實(shí)例
- PowerShell 定時(shí)執(zhí)行.Net(C#)程序的方法
- ASP.NET下使用WScript.Shell執(zhí)行命令
- 如何使用 Shell 腳本執(zhí)行 .NET Core 應(yīng)用
相關(guān)文章
PowerShell實(shí)現(xiàn)批量重命名文件
這篇文章主要介紹了PowerShell實(shí)現(xiàn)批量重命名文件,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-04-04powershell網(wǎng)絡(luò)蜘蛛解決亂碼問(wèn)題
這篇文章主要介紹了powershell網(wǎng)絡(luò)蜘蛛解決亂碼問(wèn)題,需要的朋友可以參考下2017-10-10PowerShell入門(mén)教程之遠(yuǎn)程操作運(yùn)行PowerShell的方法
這篇文章主要介紹了PowerShell入門(mén)教程之遠(yuǎn)程操作運(yùn)行PowerShell的方法,本文講解了配置遠(yuǎn)程基礎(chǔ)結(jié)構(gòu)、執(zhí)行遠(yuǎn)程操作等內(nèi)容,需要的朋友可以參考下2014-10-10Windows Powershell Switch 循環(huán)
這篇文章主要介紹了Windows Powershell Switch 循環(huán)以及PowerShell中數(shù)組可以與switch語(yǔ)句結(jié)合,產(chǎn)生意想不到的效果。2014-10-10PowerShell中改變F1幫助文檔命令獲取方式為在線文檔的方法
這篇文章主要介紹了PowerShell中改變F1幫助文檔命令獲取方式為在線文檔的方法,本文使用一個(gè)自定義函數(shù)實(shí)現(xiàn)需求,需要的朋友可以參考下2015-03-03Windows Powershell 進(jìn)行數(shù)學(xué)運(yùn)算
在Windows PowerShell中, 使用數(shù)學(xué)運(yùn)算符來(lái)進(jìn)行數(shù)學(xué)運(yùn)算,數(shù)學(xué)運(yùn)算符允許你在命令參數(shù)中計(jì)算數(shù)值. 你可以使用一個(gè)或者多個(gè)運(yùn)算符進(jìn)行加減乘除法, 也可以返回除法的余數(shù)(模). 包含這些計(jì)算的參數(shù), 將計(jì)算結(jié)果作為參數(shù)值. 命令就像處理其他類型參數(shù)一樣, 來(lái)處理參數(shù)值.2014-08-08