How to calculate the difference between two times in C#? - Biz Tech

How to calculate the difference between two times in C#?

Listen
DateTime time1 = new DateTime(2022, 3, 18, 14, 30, 0);
DateTime time2 = new DateTime(2022, 3, 18, 16, 0, 0);
TimeSpan difference = time2 - time1;
Console.WriteLine(difference.TotalMinutes);