pontoNETpt
A comunidade PontoNetPT está direccionada a todos os programadores que trabalhem com a plataforma .NET.
Nullable Types
Extracted from MSDN : Nullable Types
A comparison operator (==, !=, < , >, < =, >=) has a lifted form when the operand types are both non-nullable value types and the result type is bool. The lifted form of a comparison operator is formed by adding a ? modifier to each operand type (but not to the result type). Lifted forms of the == and != operators consider two null values equal, and a null value unequal to a non-null value. Lifted forms of the < , >, < =, and >= operators return false if one or both operands are null.
What this means is this:

int? x=null;
int? y=null;

x==y // this is true
x>=y // this is false
x< =y // this is false

Why? If they are equal why >= and < = returns false? I'm sure they have a good reason for this but I'm not getting it. If you have any idea please post a comment.

Posted 12-11-2005 11:05 por Daniel Vinagre

Comments

Anonymous wrote re: Nullable Types
on 1-7-2009 1:40
Vê a coisa deste ponto de vista:

Nada é comparável com null, excepto null.

null é igual a si próprio e diferente de tudo.

Não é maior nem menor que nada. Qualquer comparação que envolva ordem, é falsa.
Anonymous wrote re: Nullable Types
on 2-7-2009 1:58
Vê a coisa deste ponto de vista:

Nada é comparável com null, excepto null.

null é igual a si próprio e diferente de tudo.

Não é maior nem menor que nada. Qualquer comparação que envolva ordem, é falsa.

Add a Comment

(requerido)  
(opcional)
(requerido)  
Remember Me?
If you can't read this number refresh your screen
Enter the numbers above:  
Powered by Community Server (Commercial Edition), by Telligent Systems