I want to write a function that format int and decimal differently into string
I have this code:
and I want to rewrite it to generi
You could check the type of the variabele;
public static string FormatWithCommaSeperator(T value)
{
if (value is int)
{
// Do your int formatting here
}
else if (value is decimal)
{
// Do your decimal formatting here
}
return "Parameter 'value' is not an integer or decimal"; // Or throw an exception of some kind?
}