获得蜱每秒,并转换为字符串值? [英] Get Ticks per second and convert to String value?

查看:114
本文介绍了获得蜱每秒,并转换为字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何得到每DateTime.UtcNow第二刻度数,并将其转换为字符串值?

How do I get number of ticks per second of DateTime.UtcNow and convert it to a String value?

BAD问题:重试<一个href=\"http://stackoverflow.com/questions/3123894/get-ten-millionths-of-a-second\">http://stackoverflow.com/questions/3123894/get-ten-millionths-of-a-second

推荐答案

一个特定的的DateTime 不具备每滴答第二个与它相关联;蜱蜱无论哪个的DateTime 他们在,蜱是100纳秒长,所以他们有10,000,000每秒。

A particular value of DateTime doesn't have a "ticks per second" associated with it; ticks are ticks no matter which DateTime they're in. Ticks are 100 nanoseconds long, so there are 10,000,000 of them per second.

现在来获取作为字符串作为字符串文字一样简单10000000......虽然一般,你会获得一个号码,只需拨打的ToString()在上面。例如,你可以使用:

Now to get that as a string is as simple as the string literal "10000000"... although in general you would obtain a number and just call ToString() on it. For instance, you could use:

string ticksPerSecond = TimeSpan.TicksPerSecond.ToString();

您的问题是一个有点奇怪的,所以我不知道我们是否失去了一些东西......你可以编辑与更多细节你想要做什么的问题。例如,你想确定一个特定的具体第二的蜱的的DateTime ?这是最容易为已完成:

Your question is a slightly odd one, so I wonder whether we're missing something... could you edit the question with more details about what you're trying to do. For example, are you trying to determine the number of ticks within the particular second of a particular DateTime? That's most easily done as:

long ticks = dt.Ticks % TimeSpan.TicksPerSecond;

这篇关于获得蜱每秒,并转换为字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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