I want to format a string as a decimal, but the decimal contains some following zeros after the decimal. How do I format it such that those meaningless 0\'s disappear?
Somewhat hackish, but this should work:
decimal a = 100.00M; string strNumber = string.Format("{0}", a); Console.WriteLine(strNumber.Contains('.') ? strNumber.TrimEnd('0').TrimEnd('.') : strNumber);