Default value for int?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris  Ashley

    #1

    Default value for int?

    What is the default value for the int
    QuoteParameters .Quote_Claims[0].Claim_Code when it is instantiated like
    below?

    public struct Claim
    {
    public int Claim_Code;
    public System.DateTime Claim_Date;
    public bool Claim_Outstandi ng;
    public decimal Claim_Amount;
    }

    public class QuoteParameters
    {
    public Claim[] Quote_Claims = new Claim[5];
    }

    I can't do a null comparison on it, so is it a 0?

    Thanks,

    Chris

  • Arran Pearce

    #2
    Re: Default value for int?

    Its 0.

    Int is a value type which can't be null.

    If you're using .NET 2 then you can use nullable types. There is loads of
    info on MSDN about them.

    Arran

    "Chris Ashley" <chris.ashley2@ gmail.com> wrote in message
    news:1141116885 .040079.170860@ e56g2000cwe.goo glegroups.com.. .[color=blue]
    > What is the default value for the int
    > QuoteParameters .Quote_Claims[0].Claim_Code when it is instantiated like
    > below?
    >
    > public struct Claim
    > {
    > public int Claim_Code;
    > public System.DateTime Claim_Date;
    > public bool Claim_Outstandi ng;
    > public decimal Claim_Amount;
    > }
    >
    > public class QuoteParameters
    > {
    > public Claim[] Quote_Claims = new Claim[5];
    > }
    >
    > I can't do a null comparison on it, so is it a 0?
    >
    > Thanks,
    >
    > Chris
    >[/color]


    Comment

    Working...