.net - how i can declare out in parameter in powershell like c# -


i have c# code , want find alternative of code in powershell . found [ref]$parameter it's doesn't work . code :

private static bool testfunction(string param1, out string param 2) {     param1 = "";     param2 += "hello";     return true; } 

please give me alternative code in powershell.

i try :

class tst  {      static test([ref]$param)     {         $param.value  = "world "      } }  $test = "ddd" $test  [tst]::test($test) $test 

this doesn't work.

function testfunction {    param (        [string]        $param1,        [ref]        $param2    )     $param2.value= "world"    return $true }  ps c:\> $hello = "hello"  ps c:\> testfunction "somestring" ([ref]$hello) true  ps c:\> $hello world 

powershell supports ref parameters. sure call ref parameter in brackets (e.g. ([ref] $parameter). aware declare [ref]as type in paramblock. further details:

stackoverflow

ss64

hope helps

update

you've call test method ref keyword -> use [tst]::test([ref]$test) instead of `[tst]::test($test)

ps c:\> $test = "ddd"  ps c:\> $test ddd  ps c:\> [tst]::test([ref]$test)  ps c:\> $test world  

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -