My application is in C#, im trying to create a method that will convert the passed value to seconds (Time), the format that will be coming is not fixed, that be be provided by the user hence it will be dynamic. It can be **hh:mm or mm:ss or hh:mm:ss**, it can be any valid time format. The value that i will be getting from a certain file will always be a time part. The formats will be passed by the user depending on the condition / requirement. It can be any valid time format.

**I have tried** 

1. Using Timespan.Parse but it dont accept the format.
2. Using Timespan.ParseExact but my compiler is giving error that timespan dont contains the definition ParseExact.

Other option that i have add the logic for conversion to seconds depending on the format,also I dont want to add condition for every format and then use parse method. Is there any other generic way to achieve the same? such that i can pass the value and format and it should convert to seconds. Other things that i have tried are far away from being generic and specifically focus on any one format like the one in the link below

[how to convert seconds in min:sec format](https://stackoverflow.com/questions/3665012/how-to-convert-seconds-in-minsec-format)