FloatExtension.cs 496 B

12345678910111213141516171819
  1. namespace Alchemy.Core.Extensions
  2. {
  3. public static class FloatExtension
  4. {
  5. public static string ToDecimalCount(this float value, int count = 0)
  6. {
  7. string strFormat = "0";
  8. if (count < 0)
  9. strFormat = "0";
  10. else
  11. {
  12. strFormat += ".";
  13. for (int i = 0; i < count; i++)
  14. strFormat += "0";
  15. }
  16. return value.ToString(strFormat);
  17. }
  18. }
  19. }