-
Hi, {data.NullableNumber:N0} works if NullableNumber is set. I want to combine these options and tried something like {data.NullableNumber:N0:choose(null): {data.NonNullableNumber:N0} | {}} or {{data.NullableNumber:choose(null): data.NonNullableNumber | {}}:N0} but parsing fails for all of them. I guess what I want is simply {data.NullableNumber ?? data.NonNullableNumber:N0} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @mhspelt, var data = new { NullableNumber = (int?) 9876, NonNullable = (int) 1234};
var result = Smart.Format(CultureInfo.InvariantCulture, "{NullableNumber:choose(null):{NonNullable:N2}|{:N2}}", data);
// result: 9,876.00
data = new { NullableNumber = (int?) null, NonNullable = (int) 1234};
result = Smart.Format(CultureInfo.InvariantCulture, "{NullableNumber:choose(null):{NonNullable:N2}|{:N2}}", data);
// result: 1,234.00 Number format may differ depending on culture setting. |
Beta Was this translation helpful? Give feedback.
Hi @mhspelt,
Assuming you're on v2.7.0, would you agree that this works as expected?
Number format may differ depending on culture setting.