CJ7
CJ7

Reputation: 23275

Why does TimeSpan.Milliseconds evaluate to 0?

Why does TimeSpan.FromSeconds(30).Milliseconds evaluate to 0 when it would seem more correct for it to evaluate to 30000?

Upvotes: 2

Views: 421

Answers (2)

Ignacio Soler Garcia
Ignacio Soler Garcia

Reputation: 21855

You have to use TotalMilliseconds instead of Milliseconds. Milliseconds return only the part of milliseconds of the DateTime "01:01:01:342" will return 342 milliseconds.

Upvotes: 2

atkretsch
atkretsch

Reputation: 2397

TotalMilliseconds is what you are looking for. Milliseconds returns the "remainder" milliseconds (i.e. the partial second)

Upvotes: 2

Related Questions