Question: I'm trying to add comma separators to a number. I've tried the advice here: [add commas using String.Format for number and](https://stackoverflow.com/questions/2545633/add-commas-using-string-format-for-number-and) and here: [.NET String.Format() to add commas in thousands place for a number](https://stackoverflow.com/questions/105770/net-string-format-to-add-commas-in-thousands-place-for-a-number) but I can't get it to work - they just return the number without commas. The code I'm using is here:

`public static string addCommas(string cash) {
 return string.Format("{0:n0}", cash).ToString();  

 }`

Where am I going wrong?

Thanks.

---

Update: Hi all, thanks for your help, but all of those methods are returning the same error: "error CS1502: The best overloaded method match for 'BishopFlemingFunctions.addCommas(int)' has some invalid arguments" (or variations therof depending on what number type I'm using.) Any ideas?

Answer: 
In order to apply number formatting you have to pass `cash` as a number type (int, double, float etc)
Note the cash parameter is of type `double` and the `.##` at the end of the formatted string for cents.

**EDIT**

Here is the code in its entirety:

```
static class Program {
    static void Main() {
        double d = 123456789.7845;
        string s = addCommas(d);
        System.Console.WriteLine(s);
    }

    public static string addCommas(double cash) {
        return string.Format("${0:#,###0.##}", cash);
    }
}

```

This prints "$123,456,789.78" to console. If you're getting

> 
> error CS1502: The best overloaded
>  method match for 'addCommas(double)'
>  has some invalid arguments
> 
> 
> 

check to make sure that you're calling the function properly and that you're actually passing in the correct data type. I encourage you to copy/paste the code I have above and run it - BY ITSELF.