Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PowerShell calls .net static classes and methods directly

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Not all. NET Framework classes can be created using New-Object. For example, if you try to create a System.Environment or System.Math object using New-Object, you will receive the following error message:

PS> New-Object System.EnvironmentNew-Object : Constructor not found. Cannot find an appropriate constructor fortype System.Environment.At line:1 char:11+ New-Object [System.Math]::Floor(-3.3)-4PS> [System.Math]::Ceiling(3.3)4PS> [System.Math]::Ceiling(-3.3)-3PS> [System.Math]::Max(2,7)7PS> [System.Math]::Min(2,7)2PS> [System.Math]::Truncate(9.3)9PS> [System.Math]::Truncate(-9.3)-9

Use get-member to see the supported arithmetic methods for this static class:

PS> [System.Math] | Get-Member -Static -MemberType Methods TypeName: System.MathName MemberType Definition---- ---------- ----------Abs Method static System.Single Abs(Single value), static Sy... Acos Method static System.Double Acos(Double d)Asin Method static System.Double Asin(Double d)Atan Method static System.Double Atan(Double d)Atan2 Method static System.Double Atan2(Double y, Double x)BigMul Method static System.Int64 BigMul(Int32 a, Int32 b)Ceiling Method static System.Double Ceiling(Double a), static Sy... Cos Method static System.Double Cos(Double d)Cosh Method static System.Double Cosh(Double value)DivRem Method static System.Int32 DivRem(Int32 a, Int32 b, Int3... Equals Method static System.Boolean Equals(Object objA, Object ... Exp Method static System.Double Exp(Double d)Floor Method static System.Double Floor(Double d), static Syst... IEEERemainder Method static System.Double IEEERemainder(Double x, Doub... Log Method static System.Double Log(Double d), static System... Log10 Method static System.Double Log10(Double d)Max Method static System.SByte Max(SByte val1, SByte val2), ... Min Method static System.SByte Min(SByte val1, SByte val2), ... Pow Method static System.Double Pow(Double x, Double y)ReferenceEquals Method static System.Boolean ReferenceEquals(Object objA... Round Method static System.Double Round(Double a), static Syst... Sign Method static System.Int32 Sign(SByte value), static Sys... Sin Method static System.Double Sin(Double a)Sinh Method static System.Double Sinh(Double value)Sqrt Method static System.Double Sqrt(Double d)Tan Method static System.Double Tan(Double a)Tanh Method static System.Double Tanh(Double value)Truncate Method static System.Decimal Truncate(Decimal d), static...

You can also follow Weixin Official Accounts below for more content

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report