Read from configuration for a period of time (TimeSpan)

Source: Internet
Author: User

A TimeSpan for C # represents a time when DateTime represents a point in time. TimeSpan can be negative, can be added to the datetime and reduced, very convenient, I like. In the code we often want to express a period of time, with a unified unit (time or minutes or seconds), not the unit is too large, is too small, often more inconvenient. TimeSpan support from the string Parse, using our custom "When: minutes: Seconds" format, is very convenient.
TimeSpan ts1 = Timespan.parse ("-367.0:1:30.5"); TimeSpan ts2= Timespan.parse ("-367.0:1:30"); TimeSpan Ts3= Timespan.parse ("0:1:30.5"); TimeSpan TS4= Timespan.parse ("0:1:30"); TimeSpan TS5= Timespan.parse ("0:1");//represents 1 minutes instead of 1 seconds

TimeSpan supports all of the above formats and is flexible. Of course, these are just the usual ones.

Later in the code boldly use the timespan read from CONFIG. If you like it, you can have a nice ^_^

Read from configuration for a period of time (TimeSpan)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.