J
Jongmin Lee
Hi everybody,
I overloaded "operattor== " for comparing two objects.
However, I can't compare one instance to null valued
object instance.
How to solve this problem?
public class Custom
{
private int m_idx = 0;
public int Idx
{ get.... set ......}
..
..
public static bool operator ==(Custom a, Custom b)
{
//can not use if ( b == null), because endless looping
return a.Idx == b.Idx;
}
..
..
..
}
..
..
..
Custom a = new Custom();
Custom b = null;
if (b == null)
// b = a; to do something
I overloaded "operattor== " for comparing two objects.
However, I can't compare one instance to null valued
object instance.
How to solve this problem?
public class Custom
{
private int m_idx = 0;
public int Idx
{ get.... set ......}
..
..
public static bool operator ==(Custom a, Custom b)
{
//can not use if ( b == null), because endless looping
return a.Idx == b.Idx;
}
..
..
..
}
..
..
..
Custom a = new Custom();
Custom b = null;
if (b == null)
// b = a; to do something