[402] Possible NullReferenceException Warning

Why is it that the following code emits a warning for possible NullReferenceException on objInterval.Minimum:

        public override bool Equals(object obj)

        {

            Interval objInterval = obj as Interval;

            if (ReferenceEquals(objInterval, null))

                return false;

            else

                return minimum.Equals(objInterval.Minimum) && maximum.Equals(objInterval.Maximum);

        }

Whereas the following doesn't :

       public static bool operator==(Interval x, Interval y)

        {

            if (ReferenceEquals(x, null))

                return ReferenceEquals(y, null);

            else

                return x.Equals(y);

        }

]]>

Please sign in to leave a comment.