What is the difference between
if (Obj is null) Console.WriteLine("Value is null");
if (object.ReferenceEquals(Obj, null)) Console.WriteLine("Value is null");
I am trying to override the ==
operator and as such cannot use Obj == null
.
What is the difference between
if (Obj is null) Console.WriteLine("Value is null");
if (object.ReferenceEquals(Obj, null)) Console.WriteLine("Value is null");
I am trying to override the ==
operator and as such cannot use Obj == null
.
ReferenceEquals(obj, null)
and (obj is null)
do exactly the same thing, but the latter is only available as part of C# 7.0 syntax and later.