How do I format a double to currency rounded to the nearest dollar?
问题 Right now I have double numba = 5212.6312 String.Format("{0:C}", Convert.ToInt32(numba) ) This will give me $5,213.00 but I don't want the ".00". I know I can just drop the last three characters of the string every time to achieve the effect, but seems like there should be an easier way. 回答1: First - don't keep currency in a double - use a decimal instead. Every time. Then use "C0" as the format specifier: decimal numba = 5212.6312M; string s = numba.ToString("C0"); 回答2: This should do the