C# Timespan Milliseconds vs TotalMilliseconds

In the example below, why does the Milliseconds property return 0 but the TotalMilliseconds property return 5000?

// 5 seconds
TimeSpan intervalTimespan = new TimeSpan(0, 0, 5);

// returns 0
intervalTimespan.Milliseconds;

// returns 5000.0
intervalTimespan.TotalMilliseconds

Solution 1:

Simple:

  • Milliseconds are the remaining milliseconds, that don't form a whole second.
  • TotalMilliseconds is the complete duration of the timespan expressed as milliseconds.

Solution 2:

Because Milliseconds returns the Milliseconds portion, and TotalMilliseconds returns the total milliseconds represented by the Timespan

Example: 0:00:05.047

Milliseconds: 47

Total Milliseconds: 5047