I am trying to write a C# generic method that accepts nullable decimal and double values and converts them to a string representation.
I am getting the error "No overload for method 'ToString' takes 1 arguments" although I am accessing .Value
of the nullable parameter.
Here is my code. What am I doing wrong?
public static string ToThousandSeparated<T>(T? value, string naString = "") where T : struct
{
if (value.HasValue)
{
T val = value.Value;
return val.ToString("N0");
}
return naString;
}