TimeSpan

Messages
1,608
Reaction score
288
Website
tehadm.ru
C#:
TimeSpan ts = TimeSpan.Parse("12:14");
int hours = ts.Hours;
int minutes = ts.Minutes;

C#:
TimeSpan ts;
if (TimeSpan.TryParse("12:99", out ts))
{
    // the string is a valid time, use it
}
else
{
    // the string is not a valid time, handle that scenario
}
 
Back
Top