---
title: "计时器Stopwatch"
author: "devilhand"
date: "2011-05-05T09:23:04Z"
tags: []
categories: ["编程语言"]
slug: "stopwatch"
draft: false
lastmod: "2011-05-05T09:23:04Z"
id: 1029762
url: "https://devilhand.iteye.com/blog/1029762"
---

```
Stopwatch times = new Stopwatch();//设置一个计时器

times.Start();//计时器启动

times.Stop();//关闭计时器

MessageBox.Show(times.Elapsed.ToString());//打印所用时间
```