DateTime.FromBinary(Int64) Method is used to deserialize a 64-bit binary value and recreates an original serialized DateTime object.
Syntax: public static DateTime FromBinary (long dateData);
Here, it takes a 64-bit signed integer that encodes the Kind property in a 2-bit field and the Ticks property in a 62-bit field.
Return Value: This method returns an object that is equivalent to the DateTime object that was serialized by the ToBinary() method.
Exception: This method will give ArgumentException if the dateData is less than MinValue or greater than MaxValue.
Below programs illustrate the use of DateTime.FromBinary(Int64) Method:
DateTime before operation: 2010 January 01 DateTime after operation: 2010 January 01
Example 2: For ArgumentOutOfRangeException
The resulting dateData is less than the MinValue Exception Thrown: System.ArgumentException
- Difference between Method Overriding and Method Hiding in C#
- C# | Remove() Method
- Extension Method in C#
- C# | String.Contains() Method
- C# | CompareOrdinal() Method
- C# | ToLower() Method
- TimeSpan.Add() Method in C#
- Stack.Pop() Method in C#
- Method Hiding in C#
- C# | Method Overriding
- C# | Insert() Method
- C# | Replace() Method
- C# | IsNullOrWhiteSpace() Method
- C# | ToCharArray() Method
- C# | SortedDictionary.Add() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.