Interesting question

Discussion in 'ASP .Net' started by =?Utf-8?B?RGlmZmlkZW50?=, Oct 5, 2006.

  1. 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!!
    =?Utf-8?B?RGlmZmlkZW50?=, Oct 5, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?RGlmZmlkZW50?=

    Mark Rae Guest

    "Diffident" <> wrote in message
    news:...

    > 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...
    Mark Rae, Oct 5, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?RGlmZmlkZW50?=

    q Guest

    Int32 is not nullable and 0 is the default value.

    You can do this to see it.

    Int32 id = default(Int32)

    On Oct 5, 4:41 pm, Diffident <>
    wrote:
    > 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!!
    q, Oct 6, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay
    Replies:
    1
    Views:
    349
    Chris Taylor
    Oct 2, 2003
  2. =?ISO-8859-1?Q?Andreas_R=F8sdal?=

    Interesting Casting question

    =?ISO-8859-1?Q?Andreas_R=F8sdal?=, Mar 3, 2004, in forum: Java
    Replies:
    3
    Views:
    328
    Tony Morris
    Mar 3, 2004
  3. Christian Bongiorno
    Replies:
    2
    Views:
    338
    Fahd Shariff
    May 10, 2004
  4. Replies:
    6
    Views:
    384
    Ian T
    Dec 10, 2004
  5. Fran Cotton

    Very Interesting XSL Question

    Fran Cotton, Aug 5, 2003, in forum: XML
    Replies:
    3
    Views:
    441
    Erhard Schwenk
    Aug 5, 2003
Loading...

Share This Page