While writing yesterday’s post, “Getting The System Uptime In C# & .NET”, I learned that the Environment.TickCount64 returns a 64-bit integer.

I found myself wondering - what is the largest duration this can store?

I need not have looked far - there is a TimeSpan.MaxValue property that has everything we need.

Console.WriteLine($"{TimeSpan.MaxValue.TotalDays:#,0} days");
Console.WriteLine($"{TimeSpan.MaxValue.TotalHours:#,0} hours");
Console.WriteLine($"{TimeSpan.MaxValue.TotalMinutes:#,0} minutes");

This prints the following:

10,675,199 days
256,204,779 hours
15,372,286,728 minutes

These, you can see, are very long durations!

An uptime of 10 million days is about 27,000 years.

That is quite some uptime!

TLDR

The TimeSpan.MaxValue has properties that indicate the upper bounds of the largest value.

Happy hacking!