R
Rene
So I am fooling around having some fun and I came up with the class below:
class Test
{
int m_One;
int m_Two;
public void DoIt(int intNumber)
{
ref int intToUpdate; // Won't compile.
if (intNumber == 1)
intToUpdate = m_One;
else
intToUpdate = m_Two;
intToUpdate = 123 * 456;
}
}
The basic idea in the example is that I am trying to get a reference to a
value type ("m_One" or "m_Two") depending on the value of the parameter.
Then once I have the reference (by ref) to the variable I assign a value to
the reference.
In the code I am expecting to change the value on either the "m_One" or
"m_Two" variables.
This won't work even if I was to use an object variable but I just used an
int for the sake of illustration.
Anyway, if I wanted to do something similar to this would it be possible?
And by the way, this example is purely for entertainment purposes, don't ask
why am I doing this because the answer is I am not doing it, just fooling
around
Thanks!
class Test
{
int m_One;
int m_Two;
public void DoIt(int intNumber)
{
ref int intToUpdate; // Won't compile.
if (intNumber == 1)
intToUpdate = m_One;
else
intToUpdate = m_Two;
intToUpdate = 123 * 456;
}
}
The basic idea in the example is that I am trying to get a reference to a
value type ("m_One" or "m_Two") depending on the value of the parameter.
Then once I have the reference (by ref) to the variable I assign a value to
the reference.
In the code I am expecting to change the value on either the "m_One" or
"m_Two" variables.
This won't work even if I was to use an object variable but I just used an
int for the sake of illustration.
Anyway, if I wanted to do something similar to this would it be possible?
And by the way, this example is purely for entertainment purposes, don't ask
why am I doing this because the answer is I am not doing it, just fooling
around
Thanks!