Write the implementation to pass this test Given the following test, implement an addOne function in C# so it passes, without any modification to the test. TIP: Yes, it is possible.

[TestMethod]
public void TheChallenge()
{
    int a = 1;

    addOne(a);

    Assert.IsTrue(a == 2);
}


EDIT: clarified the Assert to avoid confusion. The value of a should be 2; there's no trick there.
Ummm, simply provide an implementation of AssertTrue that doesn't throw anything?

void addOne(int a){}

void AssertTrue(bool b) { }


You never specified what testing framework is used here. It looks like MSTest, but I fired up a new test project and AssertTrue doesn't exist, so I took the liberty of implementing it myself.

EDIT

This solution might be what you were fishing for:

void addOne(int x)
{
  unsafe
  {
    int* i = &amp;x;
    i += 4;
    *i += 1;
  }
}


I feels pretty fragile, but it works on my box consistently. It probably depends heavily on the compiler, so hopefully it is reproducible elsewhere.