转换的2倍之差成毫秒? [英] Convert Difference between 2 times into Milliseconds?

查看:112
本文介绍了转换的2倍之差成毫秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个蒙面TextBox控件,并想知道我怎么会去获得每一个时间,然后区别转换成毫秒。像,说,在TB1我写的12点01分,并在TB2我写的12点02分,然后单击一个按钮。一旦按钮的点击它启动一个计时器,并在12:02一个消息框会显示出来。我知道该怎么做这一切只是时间转换的部分。



如何才能实现?


解决方案

 的DateTime DT1 = DateTime.Parse(maskedTextBox1.Text); 
日期时间DT2 = DateTime.Parse(maskedTextBox2.Text);
时间跨度跨度= DT2 - DT1;
INT MS =(INT)span.TotalMilliseconds;


I have two masked TextBox controls and was wondering how I'd go about getting the time in each one and then converting the difference into milliseconds. Like, say in tb1 I write "12:01" and in tb2 I write "12:02", and then click a button. Once the button's clicked it starts a timer and at 12:02 a messagebox will be displayed. I know how to do all of it except for the time conversion part.

How can it be achieved?

解决方案

DateTime dt1 = DateTime.Parse(maskedTextBox1.Text);
DateTime dt2 = DateTime.Parse(maskedTextBox2.Text);
TimeSpan span = dt2 - dt1;
int ms = (int)span.TotalMilliseconds;

这篇关于转换的2倍之差成毫秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆