![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DateTimeOffset.ToFileTime() Method in C#
The DateTimeOffset.ToFileTime() method in C# is used to convert the value of the current DateTimeOffset object to a Windows file time. The method returns an Int64 value of the current DateTimeOffset object, expressed as a Windows file time.
Syntax
Following is the syntax −
public long ToFileTime ();
Example
Let us now see an example to implement the DateTimeOffset.ToFileTime() method −
using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset1 = new DateTimeOffset(2019, 11, 10, 6, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset1); int hash = dateTimeOffset1.GetHashCode(); long res = dateTimeOffset1.ToFileTime(); Console.WriteLine("DateTimeOffset HashCode = {0}", hash); Console.WriteLine("Windows file time = {0}", res); } }
Output
This will produce the following output −
DateTimeOffset = 11/10/2019 6:20:10 AM -05:00 DateTimeOffset HashCode = -92293937 Windows file time = 132178584100000000
Example
Let us now see another example to implement the DateTimeOffset.ToFileTime() method −
using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset1 = DateTimeOffset.Now; Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset1); long res = dateTimeOffset1.ToFileTime(); Console.WriteLine("Windows file time = {0}", res); } }
Output
This will produce the following output −
DateTimeOffset = 10/16/2019 11:16:47 AM +00:00 Windows file time = 132156982075593442
Advertisements