//Regex is in System.Text.RegularExpressions namespacepublic string RemoveTrailingZeroes(string input){ Regex reg1 = new Regex("\\.\\d*(?<1>0+)[^\\d]*$", RegexOptions.IgnoreCase); Match m = reg1.Match(input); if( m.Success ) { input = input.Replace(m.Groups["1"].Value, ""); Regex reg2 = new Regex("(?<1>\\.)[^\\d]*$", RegexOptions.IgnoreCase); m = reg2.Match(input); if( m.Success ) { input = input.Replace(".", "" ); } Regex reg3 = new Regex("\\d", RegexOptions.IgnoreCase ); m = reg3.Match(input); if( !m.Success ) { input = "0" + input; } } if(input.StartsWith(".")) input = "0" + input; return input;}