user662285 user662285 - 2 months ago 6x
C# Question

String.format for removing zero after decimal

String.Format("{0:0}",100.00) // Should show as 100 // This works fine
String.Format("{0:0}",0.5) // Should show as 0.5

But above String.Format("{0:0}" does not work.


If you need 100 and 0.5 respectively, I think the simplest String.Format("{0}", myDouble ) or even myDouble.ToString() could work.