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# | Uri.IsHexEncoding() Method
- Queue.Contains() Method in C#
- C# | Insert() Method
- C# | Replace() Method
- Anonymous Method in C#
- C# | IndexOfAny() Method
- Extension Method in C#
- C# | Uri.ToString() Method
- C# | ToLower() Method
- C# | StartsWith() Method
- C# | Math.Log() Method
- C# | Copy() Method
- C# | Remove() Method
- C# | ToUpper() 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.