I am trying to display the original value in C# three part display format. I got unexpected result + 29291221321
. I am expecting + 29.12121321
. Is this a bug or what am I doing wrong?
double value1 = 29.1221321;
string formattingString = $"+ {value1}; - {value1}; 0";
// returns "+29.1221321; -29.1221321; 0"
Console.WriteLine(value1.ToString(formattingString));
// returns "+ 29291221321"
Please refer to why i call ToString at the end. It is something known as three part format to separate outcome quickly based on +, - and 0 value https://diptimayapatra.wordpress.com/2014/01/13/3-part-format-of-numbers-in-c/
Note:
I am not expecting to hardcode by specify x numbers of # after decimal places. Please advise if there is a better method of displaying the original decimal value in three part format
string formattingString = "+ #.############; - #.############; 0";