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. Beginning Programmer needs a little help

Beginning Programmer needs a little help

Scheduled Pinned Locked Moved C#
questionhelplearning
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.
  • N Offline
    N Offline
    Nekosohana
    wrote on last edited by
    #1

    Greetings, I am working on a project that is way to big for me, but I thought I would try and tackle it anyway as an opportunity to learn more. Within my application I am trying to develop a static method that I can use to convert a time such as 1:15 (1 hour 15 minutes) to a decimal. I understand the formula, since I used it in Excel before. I need to take the input value from the user, pass it to the method, and multiply it by 24. This will give me the decimal value that I need. My question is strangly simple, and I am still just stumped by it... what data type do I need to use to get my user information into my method? It's just the colon in the user value that throws me off. Can I just take in "xx:xx" as a string value and then use "Convert.ToDecimal"? I'm sorry if I am not clear enough. If it's not, let me know and I will be happy to rephrase.

    Beginning Programmer - Still learning as much as possible.

    L 1 Reply Last reply
    0
    • N Nekosohana

      Greetings, I am working on a project that is way to big for me, but I thought I would try and tackle it anyway as an opportunity to learn more. Within my application I am trying to develop a static method that I can use to convert a time such as 1:15 (1 hour 15 minutes) to a decimal. I understand the formula, since I used it in Excel before. I need to take the input value from the user, pass it to the method, and multiply it by 24. This will give me the decimal value that I need. My question is strangly simple, and I am still just stumped by it... what data type do I need to use to get my user information into my method? It's just the colon in the user value that throws me off. Can I just take in "xx:xx" as a string value and then use "Convert.ToDecimal"? I'm sorry if I am not clear enough. If it's not, let me know and I will be happy to rephrase.

      Beginning Programmer - Still learning as much as possible.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, if the method is to accept a date, you basically have two choices: - pass it a DateTime instance - pass it a string representing a date, and use DateTime.Parse inside the method to decode it whatever you choose the method will need DateTime.Hours and DateTime.Minutes to calculate the integer value you want. I don't expect Decimal type will be of much help. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Happy 2008!


      N 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, if the method is to accept a date, you basically have two choices: - pass it a DateTime instance - pass it a string representing a date, and use DateTime.Parse inside the method to decode it whatever you choose the method will need DateTime.Hours and DateTime.Minutes to calculate the integer value you want. I don't expect Decimal type will be of much help. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Happy 2008!


        N Offline
        N Offline
        Nekosohana
        wrote on last edited by
        #3

        Thank you very much! I really appreciate it!

        Beginning Programmer - Still learning as much as possible.

        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