Re: C# Nullable types
- From: "Scott M." <s-mar@xxxxxxxxxxxxx>
- Date: Wed, 4 Apr 2007 15:20:48 -0400
Something having an unknown value is not, in any way, related to a
dissussion of null. The very word you use "unkown" implies that there is,
in fact, something to "know". A null value indicates the exact opposite of
that, that there is no value at all. That's why I said that your alaogy was
not a good one.
When I run into situations where a value is unknown to me, I set up a
variable to capture that value. After doing that, I can then look to see if
the varialbe is null, seven, "green" or anything else. The fact that I
didn't know the value of the variable does not imply null.
You seem to be discussing what a "nullable type" is, rather than the meaning
of "null".
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:esbV%23RudHHA.4188@xxxxxxxxxxxxxxxxxxxxxxx
Not sure what you meant. How would you mark that the price is unknown if
not using a "nullable" type representing a null value ? As a side note, an
empty string is not a "null" string (in the first case we known that the
value is a zero length string, in the other case we don't know what the
value is).
IMO one of the problem in discussing is that null has multiple
acceptances. In the context of a nullable type this is the same than the
"NULL" (Il'l use uppercase for this meaning) marker used in most DB, not
the "null" refererence as usual in C# (likely why MS used HasValue for
what is called "nullable" types toa void the ambiguity). VB.NET uses the
Nothing keyword.
Finally I see sometimes what is IMO an abusive use of NULL. If you know
that you have no name suffix, you don't have to use a NULL value but an
empty string will do. You have to use a NULLable column if you want to
distinguish if the value is an empty string or if it has no meaning (i.e.
not "known", "applicable" or whatever semantic you attribute to the NULL
value).
---
Patrice
"Scott M." <s-mar@xxxxxxxxxxxxx> a écrit dans le message de news:
%23NBysutdHHA.4636@xxxxxxxxxxxxxxxxxxxxxxx
I would have to disagree with your analogy.
If someting is free, it still has a value of zero dollars (as you say),
but if we don't know the price, that doesn't make the price null, it just
makes the price unkown.
null is simply a keyword that indicates that the item in question does
not have a relationship to any data at all.
A = 0 <-- A has a value of zero
A = " " <-- A has a value of the space char
A = "" <-- A has a null value (no data at all)
The benefit of null values is primarially when using databases, since
most databases have tables where not all fields are required to have a
value (like a middle name or apartment number or name suffix, such as Sr.
or Jr.). Since it is possible that a field may be null, we need a way of
checking it as such or passing null values into it.
-Scott
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:uiUEhoqdHHA.1220@xxxxxxxxxxxxxxxxxxxxxxx
For example for a price it would allow to distingusih between something
that is free (0) and something for which don't know the price (null).
It's likely you'll mostly use this for dates (if the vetn occured the
date will be filled, if the event didnt' occured date, the date will be
null).
---
Patrice
"AVL" <AVL@xxxxxxxxxxxxxxxxxxxxxxxxx> a écrit dans le message de news:
49380D43-FF22-4652-98B0-82E7C30DEC82@xxxxxxxxxxxxxxxx
hi,
i'm a new bie to c#.net 2.0....
i've come across a new feature by name nullable types...need some info
on it
what is actually a null value...
what exactly is advantage we get by specifying a value type as a null
value...
please clarify
.
- Follow-Ups:
- Re: C# Nullable types
- From: Peter Duniho
- Re: C# Nullable types
- From: Patrice
- Re: C# Nullable types
- References:
- Re: C# Nullable types
- From: Patrice
- Re: C# Nullable types
- From: Scott M.
- Re: C# Nullable types
- From: Patrice
- Re: C# Nullable types
- Prev by Date: .Net 2.0 & Dns.GetHostEntry
- Next by Date: Re: .Net 2.0 & Dns.GetHostEntry
- Previous by thread: Re: C# Nullable types
- Next by thread: Re: C# Nullable types
- Index(es):
Relevant Pages
|
Loading