How do I format a double to a string and only show decimal digits when necessary?
I have code like: lblFranshizShowInvwNoskhehEdit.Text = string.Format("{0:n}", (double)(int.Parse(drDarman["FranshizDarsad"].ToString()) * Convert.ToInt64(RadNumerictxtPayInvwNoskhehEdit.Text)) / 100); But {0:n0} string format forces the label's text to not have decimal digits and {0:n} string format forces the label's text to have 2 decimal digits (default). In my scenario I just want decimal digits when necessary / without rounding them / how can I do that? You can just do: string.Format("{0}", yourDouble); It will include only digits when necessary. If you want other examples of formatting