Search code examples
c#.netstopwatch

Stopwatch.ElapsedMillisecond Explanation


I need help with how this works. Microsoft's site doesn't have an answer so I was hoping there is a way to deal with this.

What would

stopwatch.ElapsedMilliseconds % 120000 == 0

mean?

It is in an if statement but I need to understand what is meant by that. Does it mean every 120 seconds (2 minutes), it will equal 0 and restart?


Solution

  • stopwatch.ElapsedMilliseconds % 120000 == 0
    

    this statement is checking condition on milisecond elapsed in stopwatch and is it completely divisible by 120000, if it is then ok else there might be some other condition also