Sumit Chourasia
Sumit Chourasia

Reputation: 2434

How to set enum to null if value of enum is null?

I'm passing parameter enum type nullable to my controller.

and Need to set this parameter to null without using if else condition.

I'm trying like this..

Category? categoryID = CategoryID.HasValue ? CategoryID : null ? CategoryID : CategoryID;

how can i accomplish this? help me.

Upvotes: 0

Views: 480

Answers (1)

Sumit Chourasia
Sumit Chourasia

Reputation: 2434

Got Solution for this.

Category? categoryID = CategoryID.HasValue ? CategoryID : null 

Produced the desired result for me.

Upvotes: 1

Related Questions