syntax error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Larry Foulkrod

    syntax error

    When trying to compile my application, the following line of code give me a
    syntax error:

    CaseAffiliation affiliation = (dataArray[13].GetType() ==
    System.Type.Get Type("DbNull")) ? null :
    (CaseAffiliatio n)Enum.Parse(ty peof(CaseAffili ation),
    dataArray[13].ToString());

    Where CaseAffiliation is defined as:

    public enum CaseAffiliation
    {
    BrokerDealer,
    NfpsiRia,
    OutsideRia,
    NotSecuritiesRe lated
    }

    The error is:

    Type of conditional expression can't be determined because there is no
    implicit conversion between '<null>' and 'Acr.CaseAffili ation'

    I tried looking this error up in the .net sdk but the description was a
    little over my head. Can someone explain this to me?

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: syntax error

    Larry,

    The reason for this is that CaseAffiliation is an enumeration (which is
    a value type), and there is no conversion from null to a value type. You
    need to assign a value there.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Larry Foulkrod" <lfoulkrod@nfp. com.(nospam)> wrote in message
    news:E2DFB8E7-A43A-4485-9A02-2790473B96DB@mi crosoft.com...[color=blue]
    > When trying to compile my application, the following line of code give me
    > a
    > syntax error:
    >
    > CaseAffiliation affiliation = (dataArray[13].GetType() ==
    > System.Type.Get Type("DbNull")) ? null :
    > (CaseAffiliatio n)Enum.Parse(ty peof(CaseAffili ation),
    > dataArray[13].ToString());
    >
    > Where CaseAffiliation is defined as:
    >
    > public enum CaseAffiliation
    > {
    > BrokerDealer,
    > NfpsiRia,
    > OutsideRia,
    > NotSecuritiesRe lated
    > }
    >
    > The error is:
    >
    > Type of conditional expression can't be determined because there is no
    > implicit conversion between '<null>' and 'Acr.CaseAffili ation'
    >
    > I tried looking this error up in the .net sdk but the description was a
    > little over my head. Can someone explain this to me?
    >[/color]


    Comment

    Working...