Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Need help in type casting

Need help in type casting

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashraj1982
    wrote on last edited by
    #1

    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?

    J S 2 Replies Last reply
    0
    • A Ashraj1982

      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?

      J Offline
      J Offline
      Josh Smith
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A Ashraj1982

        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?

        S Offline
        S Offline
        Saqib Mehmood
        wrote on last edited by
        #3

        char []ch = {'1','2','3','.','2','3'}; String str = new String(ch); Console.WriteLine(Convert.ToDouble(str)); Hope this would solve the problem. Saqib

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups