How can I format a decimal without separators and without decimals?
c#
Solution
This almost works, but rounds up:
Decimal d = 1234.56M;
string s = string.Format("{0:0}", d);
Console.WriteLine(s);
Outputs: `1235`
As @Jon Skeet suggested, you could cast to an integer type (assuming it was large enough to hold your largest decimal value):
Decimal d = 1234.56M;
string s = string.Format("{0}", (long)d);
Console.WriteLine(s);
Outputs: `1234`
Demo: http://ideone.com/U4dcZD
Problem
How can I format a decimal to be converted to a string without group separators and without decimals? For eg: "1,234.56" should be displayed as "1234".