nullable types. why no support for nullable string

  • Thread starter Thread starter Sakoulakis
  • Start date Start date
S

Sakoulakis

Hi,

I was just reading about nullable types and I like that feature very much.
What dissapointed me is that nullable string is not supported.

Imagine a field (of type sting) in a database which is not assigned.

I agree with nullable only for value types but in my eyes string is kind of
a mix between a value type and a reference type.

Greetings,

Sakis
 
Sakis,

A string is a reference type. You can set a string variable to null, so
Nullable<string> is not needed.

Hope this helps.
 
Sakoulakis said:
I was just reading about nullable types and I like that feature very much.
What dissapointed me is that nullable string is not supported.

Um:

string s = null;
Imagine a field (of type sting) in a database which is not assigned.

Yup - so when you assign it to a string variable on the client, you
assign the variable a value of null. Where's the problem?
I agree with nullable only for value types but in my eyes string is
kind of a mix between a value type and a reference type.

No, string is a reference type, very definitely.
 
You're right.

Thanx


Nicholas Paldino said:
Sakis,

A string is a reference type. You can set a string variable to null, so
Nullable<string> is not needed.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Sakoulakis said:
Hi,

I was just reading about nullable types and I like that feature very much.
What dissapointed me is that nullable string is not supported.

Imagine a field (of type sting) in a database which is not assigned.

I agree with nullable only for value types but in my eyes string is kind of
a mix between a value type and a reference type.

Greetings,

Sakis
 
Back
Top