You can do:

 

import System

import clr

clr.Reference[System.Array[int]]( System.Array[int]( (1,2,3) ) )

 

 

This breaks down into the array creation:

System.Array[int]( (1,2,3) )

 

And then passing that to the new instance of clr.Reference. 

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Kampas
Sent: Friday, August 25, 2006 1:43 PM
To: Discussion of IronPython
Subject: Re: [IronPython] c# function that passes arguments by reference

 

how to I create an array to pass by reference?  I assume that your example is creating an integer with a value of 3 to pass by reference.

----- Original Message -----

Sent: Friday, August 25, 2006 4:06 PM

Subject: Re: [IronPython] c# function that passes arguments by reference

 

This is the “easy” way to call functions that are passing values by reference.  You should be able to pass non-zero values as well as non-empty arrays.  The only thing that should disallow this is if there were multiple overloads that resulted in an ambiguous method resolution. 

 

For these cases there is a generic Reference type defined in the CLR module.  You can use this:

 

import clr

x = clr.Reference[int](3)

 

someObj.someFunction(x)

 

print x.Value

 

and Value will be updated after the call.

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Kampas
Sent: Friday, August 25, 2006 12:58 PM
To: users@lists.ironpython.com
Subject: [IronPython] c# function that passes arguments by reference

 

If I import a c# function that passes its arguments (integers and arrays)

by reference, the only way I can get it to work is pass zeroes for the integers and

arrays of zero for the arrays.  The results for the variables passed by reference return with the function

return.  Is that what is supposed to occur? 

_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to