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));

0

1 Answer 1

12

Cast parent.Id to an int?

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.