Parsing TimeSpan from string including format
问题 I'm sure this must be simple, but I can't figure out how to word it correctly in Google... I have a config which has a field: TimeToPoll="1d" Now I want to do something like : TimeSpan.Parse(TimeToPoll); Returning a timespan of one day. In C# EDIT: I'm looking for a method which allows parse of "1d" as well as "1s" or "1y" etc. Is this possible? Meaning: "1d" parses to {1.00:00:00} "1h" parses to {0.01:00:00} "1m" parses to {0.00:01:00} "1s" parses to {0.00:00:01} 回答1: The d is not needed and