out parameters

  • Thread starter Thread starter mike parr
  • Start date Start date
M

mike parr

I've been using out parameters to return more than 1 value from my
functions. But how do you return a variable that you have passed to the
function originally? The code below doesn't work, do I just change the
name of the variable I am passing back, or is there some clever way to
do this in C#?

private DBResult Change_CC_State(out int intNewStatus, int intNewStatus)
{
//do stuff to intNewStatus before returning
}

Thanks,

Mike
 
mike parr said:
I've been using out parameters to return more than 1 value from my
functions. But how do you return a variable that you have passed to the
function originally? The code below doesn't work, do I just change the
name of the variable I am passing back, or is there some clever way to
do this in C#?

private DBResult Change_CC_State(out int intNewStatus, int intNewStatus)
{
//do stuff to intNewStatus before returning
}

Thanks,

Mike

use this:

private DBResult Change_CC_State(ref int intNewStatus)

(see the "ref") then you can transport values both ways.


Hans Kesting
 
The error is the duplicate parameter name.

As far as getting the values. You can just pass in the variable if it's a
reference type or you can pass a value type by ref. "mike parr"
 
Back
Top