K. Turek K. Turek - 7 months ago 43
C# Question

How to convert string with colon to int?

I have string with colon, for example "10:28" and I want to convert this to int variable. I was looking for solution in System.Globalization.NumberStyles but I don't find anything. I need that to compare two different times. Maybe is there any better way to do this?

var Str1 = "10:45";
var Str2 = "10:28";

if(TimeSpan.Parse(Str1) > TimeSpan.Parse(Str2) )