Adding thousand separator to various number types 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 &lt; 0) numberOfDecimalPlaces = 0;
            return string.Format("{0:N" + numberOfDecimalPlaces + "}", value).ToString();
        }
        public static string ToThousandSeparator(this int value, int numberOfDecimalPlaces)
        {
            if (numberOfDecimalPlaces &lt; 0) numberOfDecimalPlaces = 0;
            return string.Format("{0:N" + numberOfDecimalPlaces + "}", value).ToString();
        }
        public static string ToThousandSeparator(this double value, int numberOfDecimalPlaces)
        {
            if (numberOfDecimalPlaces &lt; 0) numberOfDecimalPlaces = 0;
            return string.Format("{0:N" + numberOfDecimalPlaces + "}", value).ToString();
        }
        public static string ToThousandSeparator(this long value, int numberOfDecimalPlaces)
        {
            if (numberOfDecimalPlaces &lt; 0) numberOfDecimalPlaces = 0;
            return string.Format("{0:N" + numberOfDecimalPlaces + "}", value).ToString();
        }
        #endregion
    }
}


As you can see above , 

l have to repeat the same for 
int , decimal , long 

l can achieve the results l want but is it best

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Avo
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal tes = 294944.8484827M;
            int iint = 34;
            Console.WriteLine(tes.ToThousandSeparator(3));
            Console.WriteLine(iint.ToThousandSeparator(2)); 
            Console.ReadKey();
        }
    }
}


but is there an eloquent way of doing it , but allowing number types only.
There is no common base type for numeric types, unfortunately.

You could still reduce the repetitiveness of your code though, by encapsulating the common structure in a single function:

    private static string AddThousandsSeparator(Object numeric, int numberOfDecimalPlaces)
    {
        // note this would crash when passed a non-numeric object.
        // that's why it's private, and it's the class's responsibility
        // to limit the entry points to this function to numeric types only
        return String.Format("{0:N" + Math.Max(0, numberOfDecimalPlaces) + "}", numeric);
    }

    public static string WithThousandsSeparator(this decimal value, int numberOfDecimalPlaces)
    {
        return AddThousandsSeparator(value, numberOfDecimalPlaces);
    }

    public static string WithThousandsSeparator(this int value, int numberOfDecimalPlaces)
    {
        return AddThousandsSeparator(value, numberOfDecimalPlaces);
    }

    public static string WithThousandsSeparator(this double value, int numberOfDecimalPlaces)
    {
        return AddThousandsSeparator(value, numberOfDecimalPlaces);
    }

    public static string WithThousandsSeparator(this long value, int numberOfDecimalPlaces)
    {
        return AddThousandsSeparator(value, numberOfDecimalPlaces);
    }


A few side remarks:


There is no point in calling ToString() on the result of String.Format. String.Format already returns a string.
Math.Max is a more concise alternative for the conditional reassignment. (For what it's worth, Kotlin provides readable extension functions as syntax sugar for this sort of thing, eg.  someNumber.coerceAtLeast(0) - trivially easy to reimplement them in C# for readability).
I also corrected the naming slightly. It's "thousands" separator (plural), plus I think With... makes it clearer what the function does. The ToSomething phrase conventionally means a value is getting converted to Something, as if you were converting the number to the thousands separator itself - obviously nonsensical - rather than just adding it to the formatting.