I am trying to change the format of an object which can either be an integer or a decimal to add commas (eg., 1000 to be returned as 1,000) using below custom formatter
string temp => $"{value:n0}"
The above works fine but when the value is decimal, it removes decimal points so I came up with below format which retains decimals when the value is decimal but commas are not returned
string temp => $"{value:.#}"
May I know a better way to do this such that below results are obtained?
1000 to be returned as 1,000
13.00 to be returned as 13
13.1 to be returned as 13.1
I only want to include decimals only when they are non zero