remove seconds from timespan using c#
问题 I want to remove the seconds from timespan using c# My code is here: TimeSpan lateaftertime = new TimeSpan(); lateaftertime = lateafter - Convert.ToDateTime(intime) ; It returns the value 00:10:00 But i want the below output : 00:10 only not seconds field :00 . 回答1: Well you can simply do as string.Format("{0}:{1}", ts.Hours,ts.Minutes) // it would display 2:5 EDIT to get it properly formatted use string.Format("{0:00}:{1:00}", ts.Hours,ts.Minutes) // it should display 02:05 回答2: Note that a