Skip to content

Format 2 different variables with ChooseFormatter #198

Answered by axunonb
mhspelt asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mhspelt,
Assuming you're on v2.7.0, would you agree that this works as expected?

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.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@mhspelt
Comment options

@axunonb
Comment options

@mhspelt
Comment options

@axunonb
Comment options

@mhspelt
Comment options

Answer selected by axunonb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants