c# datetime.
DateTime.ToBinary()方法 (DateTime.ToBinary() Method)
DateTime.ToBinary() method is used to serialize the object of the DateTime class into 64-bit binary value.
DateTime.ToBinary()方法用于将DateTime类的对象序列化为64位二进制值。
Syntax:
句法:
long DateTime.ToBinary();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is long, it returns a binary value representing the DateTime object.
此方法的返回类型为long ,它返回一个表示DateTime对象的二进制值。
Example to demonstrate example of DateTime.ToBinary() method
示例,以演示DateTime.ToBinary()方法的示例
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Create object of datetime class
DateTime dt1 = new DateTime(2019,1,1,5,0,15);
//Serializes the dt1 to 64-bit binary value
long binVal = dt1.ToBinary();
//Print the value
Console.WriteLine("64-bit binary value of dt1 : " + binVal);
Console.WriteLine();
}
}
}
Output
输出量
64-bit binary value of dt1 : 636819156150000000
In the above program, we took the dt1 object of DateTime class and serialize dt1 into 64-bit value using ToBinary() method and holds the result into binVal variable and print it on the console screen.
在上面的程序中,我们使用DateTime类的dt1对象,并使用ToBinary()方法将dt1序列化为64位值,并将结果保存到binVal变量中,并将其打印在控制台屏幕上。
翻译自: https://www.includehelp.com/dot-net/datetime-tobinary.aspx
c# datetime.