Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to initialize an empty DateTime in C#
Set a DateTime to its minimum value.
DateTime.MinValue;
The above will display the minimum value i.e.
1/1/0001
Let us see how to display the minimum value and avoid adding null to a date to initialize it as empty.
Example
using System;
using System.Linq;
public class Demo {
public static void Main() {
DateTime dt = DateTime.MinValue;
Console.WriteLine(dt);
}
}
Output
1/1/0001 12:00:00 AM
Advertisements