user662285 user662285 - 1 year ago 140
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download