6

Possible Duplicate:
Conditional operator assignment with Nullable<value> types?

in the following code snippet company.ParentID is a int? and parrent a reference type. this code is a syntax error. is there anyway to fix this inline conditional??

company.ParentID = (parent == null ? null: (parent.ID));

Community
  • 1
  • 1
omid.n
  • 491
  • 5
  • 22

1 Answers1

12

Cast parent.Id to an int?

company.ParentID = (parent == null) ? null : (int?)parent.ID;

jdasilva
  • 616
  • 4
  • 9