Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Convert string to TimeSpan in C#
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { string span = "40:00"; TimeSpan ts = new TimeSpan(int.Parse(span.Split(':')[0]), // hours int.Parse(span.Split(':')[1]), // minutes 0); Console.WriteLine(ts); Console.WriteLine(Math.Round(ts.TotalHours) +":"+ts.Minutes.ToString("00") ); TimeSpan ts1=TimeSpan.Parse("05:30"); Console.WriteLine( (ts-ts1).TotalHours); } } }
run
|
edit
|
history
|
help
0
average and percentage
ss
Testing 008
Random number generator
LevenshteinDistance
valida fechas sura
TestApp
1
1
Vignere Cipher