ADVERTISEMENT
ADVERTISEMENT

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

Here, we are going to demonstrate the ToBinary() method of DateTime class in VB.Net.
Submitted by Nidhi, on January 21, 2021

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

Parameters: 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.

Program/Source Code:

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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.