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. Retrieving values from DataTable

Retrieving values from DataTable

Scheduled Pinned Locked Moved C#
questionc++
3 Posts 2 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.
  • M Offline
    M Offline
    myNameIsRon
    wrote on last edited by
    #1

    Hi, Sorry for my ignorance... I need to retrieve values (decimals) from a DataTable. What is the difference between these two methods of converting the object to a decimal and which one is best? Is there another way of retrieving decimals and keeping their native format? A: decimal labelWidth = Convert.ToDecimal(myDataTable.Rows[0]["LabelWidth"]); B: decimal labelWidth = (Decimal)myDataTable.Rows[0]["LabelWidth"]; Ron

    G 1 Reply Last reply
    0
    • M myNameIsRon

      Hi, Sorry for my ignorance... I need to retrieve values (decimals) from a DataTable. What is the difference between these two methods of converting the object to a decimal and which one is best? Is there another way of retrieving decimals and keeping their native format? A: decimal labelWidth = Convert.ToDecimal(myDataTable.Rows[0]["LabelWidth"]); B: decimal labelWidth = (Decimal)myDataTable.Rows[0]["LabelWidth"]; Ron

      G Offline
      G Offline
      Glen Harvy 0
      wrote on last edited by
      #2

      (a) They are both the same and (b) If you make labelWidth an object then you don't need to do a conversion to decimal at that time. object labelWidth = myDataTable.Rows[0]["LabelWidth"]; Never apologise for your ignorance - we all have it :)

      Glen Harvy

      M 1 Reply Last reply
      0
      • G Glen Harvy 0

        (a) They are both the same and (b) If you make labelWidth an object then you don't need to do a conversion to decimal at that time. object labelWidth = myDataTable.Rows[0]["LabelWidth"]; Never apologise for your ignorance - we all have it :)

        Glen Harvy

        M Offline
        M Offline
        myNameIsRon
        wrote on last edited by
        #3

        Thanks Glen! Ron

        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