You should have broken out the detail:
string str = "44.22";
double d = Convert.ToDouble(str);
Console.WriteLine("the d val" + d);
double c;
int doll;
int cent;
doll = (int)d;
Console.WriteLine(doll);
c = d - doll;
cent = (int)(c * 100);
Console.WriteLine(cent);
int cents = (int)(d * 100);
int dollars = cents / 100;
cents = cents % 100;
What happens is that you are using a truncate when you use the cast.
You can also use the
Convert.ToInt32(c *100)
because that does not give you the same truncate error as casting.