Posts

Showing posts from April 4, 2019

Adding thousand separator to various number types

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0; 3 $begingroup$ Am making a pure .net library with helper functions (GitHub). However I wanted to have a thousand separator for all number types and here is what I am currently doing using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Avo public static class Extension_Number #region ThousandSeparator public static string ToThousandSeparator(this decimal value, int numberOfDecimalPlaces) if (numberOfDecimalPlaces < 0) numberOfDecimalPlaces = 0; return string.Format("0:N" + numberOfDecimalPlaces + "", value).ToString(); public static string ToThousandSeparator(this int value, int numberOfDecimalPlaces) if (numberOfDecimalPlaces < 0) numberOfDecimalPlaces = 0; return string.Format("0:N" + num