This function returns 2 decimal places without rounding. This function requires to pass decimal value parameter.
private string FormatDecimal(decimal val)
{
decimal newValue = ((Int64)(val * 100)) / 100m;
return newValue.ToString("N2");
}
for example:
decimal dValue = 22221111.8055234M;
string newValue = FormatDecimal(dValue);
Output:
newValue = 22,221,111.80
No comments:
Post a Comment