A nice little pitfall for the unaware: I'm not certain if this a compiler bug or a WTF in the C# specs. Assume the following class:
class Class1
{
private int i = 0;
public int pi
{
set {
i = value;
}
get {
return(i);
}
}
}
Now do this:
class = new Class1();
++class.pi;
After the increment, class.pi will equal.... zero. Stepping through in the VS debugger you'll see it enter the get block, return it, and then drop the value on the floor and ignore the implicit assignment. However:
class.pi += 1;
And class.pi will equal one.