Assigning null value to DateTime

B

Bill Gower

How do I assign a null value to a datetime variable?

DateTime DateNonMember = DateTime.Parse("").ToString();

This doesn't work.

I also tried

DateTime DateNonMember = DBNull.Value


Bill
 
T

Tim Van Wassenhove

Bill Gower schreef:
How do I assign a null value to a datetime variable?
DateTime DateNonMember = DBNull.Value


DateTime is a value type so you can't assign null to it.
You can assign null to Nullable<DateTime> (DateTime? in c#)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SqlDateTime and DateTime 2
Problems with nullable DateTime 4
Question about DateTime 3
transfer data from Dictionary to DataTable 2
Date formatting on DateTime? 4
C# SQLCommand 3
need to assign null 3
DateTime Null 2

Top