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
- Queue.Contains() Method in C#
- DateTimeOffset.Add() Method in C#
- C# | Math.Abs() Method | Set - 1
- C# | Math.Abs() Method | Set - 2
- C# | Math.Exp() Method
- Anonymous Method in C#
- TimeSpan.Add() Method in C#
- C# | Uri.FromHex() Method
- C# | String.Contains() Method
- C# | Random.Next() Method
- C# | Uri.IsHexDigit() Method
- C# | Math.Tan() Method
- C# | IndexOfAny() 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.