This code works (C# 3)
double d; if(d == (double)(int)d) ...;
You don't need the extra (double) in there. This works:
if (d == (int)d) { //... }