2
Answers

Specified cast not valid.

I am using .NET Framework 4.0 and recently came across a strange problem.

Cast to decimal (decimal)row["ID"] fails with "Specified cast not valid" where row["ID"] is of datatype Int64 and a value of 38990 :

However if i use Convert.ToDecimal(row["ID"]) it works.

Why is the behaviour not consistent - am i missing something here ?

Regards,
Prem
Answers (2)