Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell, interactively invoking a static method

I'm sitting at a PowerShell command prompt and following http://technet.microsoft.com/en-us/library/dd347632.aspx

PS C:\> [System.Math]::Sqrt (9)
Unexpected token '(' in expression or statement.
At line:1 char:22
+ [System.Math]::Sqrt ( <<<< 9)
  + CategoryInfo          : PArserError: ((:String) [], ParentContainsErrorRecordException
  + FullyQualifiedErrorId : UnexpectedToken

Am I being tricked or did the tutorial give me something that has a syntax error?

How do I do a basic thing like invoke a static method?

like image 204
clemahieu Avatar asked Nov 26 '25 10:11

clemahieu


1 Answers

Don't have the space after Sqrt:

[System.Math]::Sqrt(9)
like image 162
manojlds Avatar answered Nov 29 '25 02:11

manojlds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!