This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
Lemonade/Lemonade/DollarConv.cs

17 lines
473 B
C#

using System.Globalization;
namespace Lemonade
{
public static class DollarConv
{
public static string ToDollar(this int cents)
{
string tmp = $"${(cents / 100f).ToString(CultureInfo.InvariantCulture)}";
if (tmp.Length > 1 && tmp[1] == '-')
tmp = "-$" + tmp.Substring(2);
if (tmp.Contains('.') && tmp.Split('.')[1].Length < 2)
tmp += '0';
return tmp;
}
}
}