Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is string nullable? [duplicate]

Tags:

c#

.net

Possible Duplicate:
The type ‘string’ must be a non-nullable type in order to use it as parameter T in the generic type or method ‘System.Nullable<T>’

As the title says, why are strings nullable by default in C#, but if I want, say, ints or doubles to be null, I have to explicitly say so?

like image 711
Paul McLean Avatar asked Jan 17 '13 01:01

Paul McLean


1 Answers

Because string is a reference type, deriving from object and [most] other default types are value types, deriving implicitly from System.ValueType;

like image 181
RJ Lohan Avatar answered Sep 19 '22 22:09

RJ Lohan