i am doing a simple conversion from decimal to string and stripping trailing zeros like so:
argCat.ToString("0.##")
however, i keep getting the following error:
Conversion from string "0.##" to type 'Integer' is not valid.
am i missing something?
This would happen if argCat is of a type that does not have a ToString() overload that accepts a parameter.
In such a case, your code is parsed as ToString()("0.##"); the "0.##" becomes an argument to the indexer in the String returned by ToString().
You then get this misleading error because that indexer takes an int, not a string.
string str = String.Format("{0:C}", argCat);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With