Interesting question

  • Thread starter Thread starter Guest
  • Start date Start date
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!!
 
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...
 
Int32 is not nullable and 0 is the default value.

You can do this to see it.

Int32 id = default(Int32)
 
Back
Top