C# string format best overloaded method match error -


i unfamiliar c#, bear me.

private static string getformattedvalue(string datatype, dynamic cellvalue)     {         string formattedcellvalue = string.empty;         if (cellvalue == null)             cellvalue = dbnull.value;          if (datatype == "string")         {             formattedcellvalue = string.format("'{0}',", cellvalue);         }         else if (datatype == "number")         {             if (string.isnullorempty(convert.tostring(cellvalue)))                 cellvalue = 0;             formattedcellvalue = string.format("'{0}',", cellvalue.tostring("f17"));         }         else if (datatype == "date")         {             formattedcellvalue = string.format("'{0}',", cellvalue);         }         else         {             formattedcellvalue = string.format("'{0}',", cellvalue.tostring("f17"));         }          return formattedcellvalue; 

when datatype number , cellvalue whole number, error stating: "the best overloaded method match string.tostring(system.iformatprovider) has invalid arguments"

cellvalue extremely small numbers that, without "f17", returned scientific notation (which causes error down line), whole numbers cause error above.

this not code, i'm running , know enough step through it. ideas how determine if cellvalue can read determine if whole number or not? or other better suggestion?

there numerous methods tries parse string number, such double.tryparse


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -