What I would like to do is be able to pass any number of variables into a function, manipulate those variables inside of the function, and have access to those manipulations outside of the scope of the function.
Example
void FunctionA()
{
int x = 1;
string s = "blah";
int y = 4;
FunctionB(out x, out s, out y);
Console.WriteLine("{0}, {1}, {2}", x, s, y);
}
void FunctionB(out params object[] parameters)
{
for(int ii = 0; ii < parameters.Length; ii++)
{
if(parameters[ii] is int) parameters[ii] = (int)parameters[ii] + 1;
}
}
After calling FunctionA() the console should have "2, blah, 5" on it. Is there a way to do this short of returning an object[] and parsing out the variables I want?
For clarification, here is what I'm attempting to do. Pass a byte[] into a function along with a slew of variables. Attempt to read information out of the byte[] and assign it to the variables that were passed in. So if I had an int, a string, and another int written to a byte[] and I pass in something like:
int x, y;
string s;
byte[] info = ...;
FunctionB(info, x, s, y);
Console.WriteLine("{0}, {1}, {2}", x, s, y);
It would output the information from the byte[].