Equality operators (== and !=) on Nullable - CSharp Language Basics

CSharp examples for Language Basics:Nullable

Introduction

Lifted equality operators handle nulls just like reference types do. This means two null values are equal:

Console.WriteLine (       null ==        null);   // True
Console.WriteLine ((bool?)null == (bool?)null);   // True

If exactly one operand is null, the operands are unequal.

If both operands are non-null, their Values are compared.


Related Tutorials