立即获取时间而不使用DateTime.now [英] obtain time now without use DateTime.now
本文介绍了立即获取时间而不使用DateTime.now的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我想知道如何在不使用类DateTime的情况下现在获取时间
我尝试创建我的特殊上课日期
感谢您的回答:)
hello everyone
i want to know how can i obtain time now without use class DateTime
i try to create my special class date
thanks for your answer :)
推荐答案
如果您使用的是.NET语言,则应使用.NET函数-您可以通过 GetSystemTime [
If you are using a .NET language, then you should use .NET functions - you could get the time by PInvoke of GetSystemTime[^]:
[DllImport("kernel32.dll")]
static extern void GetSystemTime(out SYSTEMTIME lpSystemTime);
但是您需要声明SYSTEMTIME结构并自行处理.
But then you need to declare the SYSTEMTIME structure and process it yourself.
[StructLayout(LayoutKind.Sequential)]
public class SystemTime
{
public ushort year;
...
public ushort milliseconds;
}
为DateTime.Now属性提供一个包装器类将是一个更好的解决方案.
Providing a wrapper class for the DateTime.Now property would be a better solution.
这篇关于立即获取时间而不使用DateTime.now的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文