is there framework way to know if there are numbers after point for printing.
i want to show in textbox some decimal but if there is no numbers after the point
the text should show int
like that:
txt.Text=(x - Math.Floor(x) > 0)?x.ToString("2f"):((int)x).ToString();
Try this:
This displays the decimal point only when it is necessary.
As an aside, in the code you posted you should use
x.ToString("f2")rather thanx.ToString("2f").