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. Calculate time with int

Calculate time with int

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 4 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
    andredani
    wrote on last edited by
    #1

    Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100. for example 00:00:10 / 10 *100 Gonna count the time of 100 pages... big reggards!! Thanks

    M G 2 Replies Last reply
    0
    • A andredani

      Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100. for example 00:00:10 / 10 *100 Gonna count the time of 100 pages... big reggards!! Thanks

      M Offline
      M Offline
      Matthew Cuba
      wrote on last edited by
      #2

      andredani wrote:

      Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100. for example 00:00:10 / 10 *100 Gonna count the time of 100 pages...

      Have you taken a look at the DateTime and TimeSpan classes? I suspect that would provide you with the answer. Good Luck!

      It isn't enough to do well in life. One must do good when and where one can. Otherwise, what's the point?

      L 1 Reply Last reply
      0
      • M Matthew Cuba

        andredani wrote:

        Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100. for example 00:00:10 / 10 *100 Gonna count the time of 100 pages...

        Have you taken a look at the DateTime and TimeSpan classes? I suspect that would provide you with the answer. Good Luck!

        It isn't enough to do well in life. One must do good when and where one can. Otherwise, what's the point?

        L Offline
        L Offline
        Larantz
        wrote on last edited by
        #3

        I'd go with what Matthew said. But why are you multiplying the pages by 100? Using pseudo-code, you've written: TimeSpent / NrOfPages * 100 Best regards! -Larantz-

        for those about to code, we salute you
        http://www.itverket.no

        Please refer to the Forum Guidelines for appropriate posting.

        1 Reply Last reply
        0
        • A andredani

          Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100. for example 00:00:10 / 10 *100 Gonna count the time of 100 pages... big reggards!! Thanks

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          The TimeSpan structure has a Ticks property that gives you the time as a long value, and a constructor that takes a long value. Example:

          TimeSpan duration = new TimeSpan(0, 0, 10);
          int ticks = (int)duration.Ticks;
          int pages = 10;
          int calculatedTicks = ticks * 100 / pages;
          TimeSpan calculatedTime = new TimeSpan((long)calculatedTicks);

          --- single minded; short sighted; long gone;

          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