syntax error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

CaseAffiliation affiliation = (dataArray[13].GetType() ==
System.Type.GetType("DbNull")) ? null :
(CaseAffiliation)Enum.Parse(typeof(CaseAffiliation),
dataArray[13].ToString());

Where CaseAffiliation is defined as:

public enum CaseAffiliation
{
BrokerDealer,
NfpsiRia,
OutsideRia,
NotSecuritiesRelated
}

The error is:

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

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?
 
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.
 
Back
Top