c# - convert decimal? in primitive decimal -
i want convert nullable decimal primitive decimal. how this. have done googling , found system.componentmodel.nullableconverter 1 of solution. not able figure out how use it.
decimal? offenceamount = 23; decimal primitive; primitive=offenceamount; //   please help.
you can do:
if (offenceamount.hasvalue) {     primitive = offenceamount.value; }   or, if want result default 0:
primitive = offenceamount.getvalueordefault();   or shortcut above:
primitive = offenseamount ?? 0;      
Comments
Post a Comment