DavidB
DavidB

Reputation: 2596

Nullable (of date) things to consider when converting

I have been asked to find out why an ajax call doest work if date fields are left blank on a web form, finding out was easy, its because the VB function expects an object with a Date type.

I'm going to convert these values to Nullable(Of Date), but I'm reluctant as this is a class that's quite heavily used and I don't want to break anything else.

My thinking however is that everything calling this class must be sending in a correct Date or it would throw an error currently, so I should be ok.

As long as I check for a value using HasValue and get the date out using Value then I shouldn't have any problems, or is there something else I need to consider?

Upvotes: 1

Views: 117

Answers (1)

Rob Sedgwick
Rob Sedgwick

Reputation: 4514

If you change every reference to use the Date's Value property it will be no worse than what you have now. Then you can add the HasValue checks where you need to.

Upvotes: 1

Related Questions