Answers for "c# tostring format decimal"

C#
1

c# format decimal as currency

private decimal _amount;

public string FormattedAmount
{
    get { return string.Format("{0:C}", _amount); }
}
Posted by: Guest on October-21-2020
0

c# tostring decimal 2 places

decimalVar.ToString("0.##"); // returns "0.5"  when decimalVar == 0.5m
Posted by: Guest on August-29-2021
1

c# format decimal as currency

private decimal? _amount;
// For nullable decimals
public string FormattedAmount
{
    get
    {
         return _amount == null ? "null" : string.Format("{0:C}", _amount.Value);
    }
}
Posted by: Guest on October-21-2020
0

c# tostring decimal 2 places

decimalVar.ToString("0.00"); // returns "0.50"  when decimalVar == 0.5m
Posted by: Guest on August-29-2021

C# Answers by Framework

Browse Popular Code Answers by Language