Stopwatch Constructor
Collapse the table of content
Expand the table of content

Stopwatch.Stopwatch Constructor

Initializes a new instance of the Stopwatch class.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public Stopwatch ()
public Stopwatch ()
public function Stopwatch ()
Not applicable.

The returned Stopwatch instance is stopped, and the elapsed time property of the instance is zero.

Use the Start method to begin measuring elapsed time with the new Stopwatch instance. Use the StartNew method to initialize a new Stopwatch instance and immediately start it.

The following example initializes a Stopwatch instance within a simple class constructor. This code example is part of a larger example provided for the Stopwatch class.

private Stopwatch stopWatch;
private Boolean captureLap;

public FormMain()
{
    stopWatch = new Stopwatch();
    captureLap = false;

    InitializeComponent();
}

private Stopwatch stopWatch;
private Boolean captureLap;

public FormMain()
{
    stopWatch = new Stopwatch();
    captureLap = new Boolean(false);

    InitializeComponent();
} //FormMain

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2016 Microsoft