Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:32:00+00:00 2026-05-14T15:32:00+00:00

How to parse string like 30:15 to TimeSpan in C#? 30:15 means 30 hours

  • 0

How to parse string like 30:15 to TimeSpan in C#? 30:15 means 30 hours and 15 minutes.

string span = "30:15";
TimeSpan ts = TimeSpan.FromHours(
    Convert.ToDouble(span.Split(':')[0])).
  Add(TimeSpan.FromMinutes(
    Convert.ToDouble((span.Split(':')[1]))));

This does not seem too elegant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:32:01+00:00Added an answer on May 14, 2026 at 3:32 pm

    If you’re certain that the format will always be “HH:mm” then try something like this:

    string span = "35:15";
    TimeSpan ts = new TimeSpan(int.Parse(span.Split(':')[0]),    // hours
                               int.Parse(span.Split(':')[1]),    // minutes
                               0);                               // seconds
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse apart a string like this with javascript: var mystr =
I need to parse a string like this: a[metadata][][name]=dont|do|this&a[name]=Hello World&a[metadata][][value]=i|really|mean it CGI::parse gives me
I am trying to parse a String like this: f2cff0a43553b2e07b6ae3264bc085a into a BigInt however
I'm trying to use regexp to parse a string like similar to this: <tag>Text
i want parse string like this 0.1142 0.0000 0.0000 0.0004 0.0000 0.0000 2299/2299 MakeRequest
Is in ocaml function which can parse string like this [(1,2,3);(1,2,5);(2,3,4)] into (int*int*int) list
I am trying to parse a string something like this: Input 20:00 - output
I'm trying to parse a JSON string like this one [ { updated_at:2012-03-02 21:06:01,
Sometimes I get a string like 02:40 indicating 2 hours and 40 minutes. I'd
I would like to parse a string like this: -o 1 --long Some long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.