difference between (int) and convert.toint32 in c#

Posted by 4thpage Media and services on Stack Overflow See other posts from Stack Overflow or by 4thpage Media and services
Published on 2010-06-17T04:55:21Z Indexed on 2010/06/17 5:03 UTC
Read the original article Hit count: 174

Filed under:
|

when i convert a object to int by

(int)object

then when the object value is 0 then he give me error that specific cast not valid.

when i convert a object to int by

convert.toint32(object)

then he works and give me 0 means cast is valid.

and i want to know that what is difference between both.

1. (int)object
2.convert.toint32(object)

© Stack Overflow or respective owner

Related posts about c#

Related posts about programming-languages