You can do:
if (offenceAmount.HasValue) {
primitive = offenceAmount.Value;
}
Or, if you want the result to be equal by default 0:
primitive = offenceAmount.GetValueOrDefault();
Or a shortcut for the above:
primitive = offenseAmount ?? 0;
source
share