c# - Defining operators and testing for null -
i have class in c# define operator ==. method have throws object null exception when testing following
myclass = new myclass(); if(a==null).... this frustrating because in definition of operator can't ask if either parameter null because go infinite recursion.
how test see if either parameter null when defining == operator.
if (object.referenceequals(obja, null)) { ... } another option cast obja object:
if ((object)obja == null) { ... } you may want consult these guidelines.
Comments
Post a Comment