¿Cómo implemento esta funcionalidad? Creo que no funciona porque lo guardo en el constructor. ¿Debo hacer algo de box/unbox jiberish?pase el valor por referencia en el constructor, guárdelo, luego modifíquelo más tarde, ¿cómo?
static void Main(string[] args)
{
int currentInt = 1;
//Should be 1
Console.WriteLine(currentInt);
//is 1
TestClass tc = new TestClass(ref currentInt);
//should be 1
Console.WriteLine(currentInt);
//is 1
tc.modInt();
//should be 2
Console.WriteLine(currentInt);
//is 1 :(
}
public class TestClass
{
public int testInt;
public TestClass(ref int testInt)
{
this.testInt = testInt;
}
public void modInt()
{
testInt = 2;
}
}
Gracias, eso fue muy útil. –