Need help in type casting
-
Hi, I'm converting char[] to double using Dlength = System.Convert.ToDouble(strdata); But its throwing exception called "Unable to cast object of type 'System.char[]' to type 'System.IConvertible'. Any idea?
-
Hi, I'm converting char[] to double using Dlength = System.Convert.ToDouble(strdata); But its throwing exception called "Unable to cast object of type 'System.char[]' to type 'System.IConvertible'. Any idea?
Assuming that the char[] contains something like { '9', '.', '2', '5' } then you should convert the array into a string, then pass that into the ToDouble method. Josh
-
Hi, I'm converting char[] to double using Dlength = System.Convert.ToDouble(strdata); But its throwing exception called "Unable to cast object of type 'System.char[]' to type 'System.IConvertible'. Any idea?
char []ch = {'1','2','3','.','2','3'}; String str = new String(ch); Console.WriteLine(Convert.ToDouble(str));
Hope this would solve the problem. Saqib