![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | Passing ArrayList as reference to function I'm trying to pass ArrayList as [ref] to a function without any success. I tried .Add which fails because [ref] deosn't have Add method. I tried casting but to no avail. Does any one have any sample code? thanks. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Passing ArrayList as reference to function function RefTest { param( [REF]$refVar ) $refVar.Value = 1 } $intVar = 0 "`$intVar = $intVar" RefTest ([REF]$intVar) "`$intVar = $intVar" -- Kirk Munro [MVP] Poshoholic http://poshoholic.com "RD" <RD@xxxxxx> wrote in message news:B280F97F-5ECF-4CA9-BF2C-6704F51AC00D@xxxxxx Quote: > I'm trying to pass ArrayList as [ref] to a function without any success. I > tried .Add which fails because [ref] deosn't have Add method. I tried > casting > but to no avail. Does any one have any sample code? thanks. |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Passing ArrayList as reference to function To follow up on your specific issue, you probably need to do $myRefVar.Value.Add inside your function to get it to work. When working with reference variables, you need to use .Value to get the actual variable that is being referenced so that you can call methods, assign values, etc. -- Kirk Munro [MVP] Poshoholic http://poshoholic.com "RD" <RD@xxxxxx> wrote in message news:B280F97F-5ECF-4CA9-BF2C-6704F51AC00D@xxxxxx Quote: > I'm trying to pass ArrayList as [ref] to a function without any success. I > tried .Add which fails because [ref] deosn't have Add method. I tried > casting > but to no avail. Does any one have any sample code? thanks. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Thread-safety: Change property of items in arraylist versus removingitems from the arraylist | .NET General | |||
| Passing dataset by reference between forms, what is the best approach? | .NET General | |||
| Passing hash table by reference | PowerShell | |||
| Passing arguments to a function | PowerShell | |||
| passing variable by reference | PowerShell | |||