Convert Time to decimal in C#

Can we take the time value is roughly at 10:30:00

Type1
 
decimal output= Convert.ToDecimal(TimeSpan.Parse("10:30").TotalHours);
Net Approch will be 2 nd Type is

var startTime=TimeSpan.Parse("10:30");
var endTime=TimeSpan.Parse("11:30");
var result=endTime -  startTime;
decimal output= result.Hours+result.Minites/60;

Here minites should be reater than 0.



Comments

Popular posts from this blog

Reverse Sentence using c#

How to write Pure java script Program?