Pages

Thursday, October 31, 2013

DateTime minvalue in C#.Net

Here we discuss about set DateTime.MinValue. When you try to assign a DateTime to the null literal in the C# language, The compiler will give an error "Cannot convert null to System.DateTime".

Instead of assigning the DateTime to null, you can use the readonly field DateTime.MinValue

Example :

DateTime date1;
date1=DateTime.MinValue

Output :

1/1/0001 12:00:00 AM