Nayrb
Nayrb

Reputation: 1043

Timespan in C# converting to int? Somehow?

I'm trying to use the Timespan class to create a start time and a stop time, get the difference and ultimately dividing and multiplying the result against another number.

The problem is getting into something I can work with.

Any suggestions?

Upvotes: 1

Views: 6843

Answers (2)

Steven Evers
Steven Evers

Reputation: 17216

If you're trying to measure code running time, the stopwatch class might be more appropriate.

Upvotes: 4

Michael
Michael

Reputation: 20069

The TimeSpan class has a number of members which might be able to assist, for instance TotalSeconds, TotalMinutes, TotalHours etc.

If you want to know the number of operations per second, divide the number of operations by the TotalSeconds member of the TimeSpan object.

Upvotes: 9

Related Questions