Friday, July 2, 2010

Unboxing, Casting

int totalPage = (int)(long)cmdCount.ExecuteScalar();

That is not double casting. The first(read from right to left) cast, is actually unboxing, we unbox long from object, then cast the long type to int type

Unboxing shares the same syntax of casting

No comments:

Post a Comment