Assigning null value to DateTime

  • Thread starter Thread starter Bill Gower
  • Start date Start date
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
 
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

Back
Top