Interesting question

G

Guest

Hi All,

Can anyone explain me why when I convert a null object to an 32-bit integer
the result is zero?

Convert.ToInt32(null) = 0?

Thanks!!
 
M

Mark Rae

Can anyone explain me why when I convert a null object to an 32-bit
integer
the result is zero?

Convert.ToInt32(null) = 0?

Because the default value of an int variable is zero...
 
Q

q

Int32 is not nullable and 0 is the default value.

You can do this to see it.

Int32 id = default(Int32)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top