Why 10675199.02: 48: 05.4775807 TimeSpan Maximum for CompilationSection?

I looked at the metadata for System.Web.Configuration.CompilationSection and noticed the following attribute of the TimeSpan BatchTimeout :

 [TimeSpanValidator(MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")] 

Can someone explain why this is a valid maximum value? TimeSpan itself has an upper limit, so why do we need another check of the value and why is this number?

+6
c # validation timespan
source share
2 answers

This is exactly the maximum value of TimeSpan . MSDN quoting for TimeSpan.MaxValue :

The value of this field is equivalent to Int64.MaxValue. The string representation of this value is positive 10675199.02: 48: 05.4775807.

+7
source share

I think that the accepted answer does not fully answer the question. This is really the same maximum value. And this is no coincidence. But why is this definition:

 [TimeSpanValidator(MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")] 

not something like:

 [TimeSpanValidator(TimeSpan.Zero, TimeSpan.MaxValue)] 

?

Well, just put it, it's because Attributes don't allow second-class definitions. They only allow compilation of time constants, because they are metadata compiled into an assembly.

+8
source share

All Articles