Parse string in HH.mm format to TimeSpan

后端 未结 6 1592
栀梦
栀梦 2020-12-06 03:57

I\'m using .NET framework v 3.5 and i need to parse a string representing a timespan into TimeSpan object.

The problem is that

6条回答
  •  眼角桃花
    2020-12-06 05:00

    string YourString = "01.35";
    
    var hours = Int32.Parse(YourString.Split('.')[0]);
    var minutes = Int32.Parse(YourString.Split('.')[1]);
    
    var ts = new TimeSpan(hours, minutes, 0);
    

提交回复
热议问题