- public string FormatAmount(decimal? amount = null)
- {
- amount = amount ?? Amount;
- var s = amount.ToString();
- if (s.Length < 2)
- {
- return s;
- }
- var len = s.IndexOf('.');
- if (len < 0)
- {
- len = s.Length;
- }
- if (len < 4)
- {
- return s;
- }
- for (var i = len-3; i > 0; i -= 4)
- {
- s = s.Insert(i, ",");
- i++;
- }
- return s;
- }