この機能を実装するにはどうすればよいですか?私はそれがコンストラクタに保存するので、動作しないと思いますか? Box/Unbox jiberishをする必要がありますか?コンストラクタで参照渡しの値を渡して保存し、後でそれを変更します。
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;
}
}
おかげで、それは本当に役に立ちました。 –