BlueCell wrote:
Imagine I have this:
Dim a as integer = 3
Dim b as integer = a
a = 6
The result:
a = 6; b = 3
How to get this result:
a = 6; b = 6
As in... when changing a, I would like b to change aswell.
Thnx,
Michel vd Berg
The only way to do that in managed code is to wrap the integers (value types) into reference types.
C# example
public class MyClass
{
public static void Main()
{
W a = new W(3);
W b = a;
a.a = 6;
Console.WriteLine( "a = {0}\nb = {1}", a.a, b.a );
Console.WriteLine( "Press enter to exit." );
Console.ReadLine();
}
class W
{
public int a;
public W( int a )
{
this.a = a;
}
}
}