Java System.currentTimeMillis() equivalent in C#

前端 未结 11 1089
-上瘾入骨i
-上瘾入骨i 2020-12-13 01:18

What is the equivalent of Java\'s System.currentTimeMillis() in C#?

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 02:03

    If you are interested in TIMING, add a reference to System.Diagnostics and use a Stopwatch.

    For example:

    var sw = Stopwatch.StartNew();
    ...
    var elapsedStage1 = sw.ElapsedMilliseconds;
    ...
    var elapsedStage2 = sw.ElapsedMilliseconds;
    ...
    sw.Stop();
    

提交回复
热议问题