I have a little confusion with the following things:
- Null
- DBNull.Value
- “”
When I use Conditional Statements OR while assigning values, I am a little bit confused with these things. Sometimes it throws error and some times it works. I want to know when I want to use the above things. Are they specific with datatypes? I need your valuable suggestions please.
nullis one of two things:0as a reference)Nullable<T>struct, which does not currently have a value (theHasValueproperty will also returnfalse)DBNullis specific to some parts of ADO.NET to representnullin the database. I have yet to think of a good reason why they didn’t just use regularnullhere.""is a string literal with length zero – a perfectly valid, but empty, string. The significance of this is that betweennullstring and a""string, instance methods likevalue.Trim()will behave differently;null.Trim()will throw an exception;"".Trim()is just"". In general, usingstring.IsNullOrEmpty(value)as a test makes this distinction go away.