×

VB.Net Programs

VB.Net program to demonstrate the ToBinary() method of DateTime class

By Nidhi Last Updated : November 14, 2024

DateTime.ToBinary() Method in VB.Net

The ToBinary() method is used to serializes the current Date object to a 64-bit binary value that subsequently can be used to recreate the Date object.

Syntax

Function ToBinary() as Long

Parameter(s)

There is no parameter.

Return Value

It returns a long value that represents a 64-bit binary value that subsequently can be used to recreate the Date object.

VB.Net code to demonstrate the example of DateTime.ToBinary() method

The source code to demonstrate the ToBinary() method of the DateTime class is given below. The given program is compiled and executed successfully.

'VB.NET program to demonstrate ToBinary() method of 
'DateTime class.

Imports System

Module Module1
    Sub Main()
        Dim ddate As New DateTime(2020, 4, 27, 10, 20, 30)

        Dim bin As Long = 0

        bin = ddate.ToBinary()

        Console.WriteLine("Binary value: {0}", bin)
    End Sub
End Module

Output

Binary value: 637235796300000000
Press any key to continue . . .

Explanation

In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program.

In the Main() function, we created an object of the DateTime class and get serializes the current Date object to a 64-bit binary value using ToBinary() method of the DateTime class. After that, we printed the returned value on the console screen.

VB.Net Date & Time Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.