csharp:: 연산자 == equal()

 

 

 

 

public static bool operator ==(MyClass op1, MyClass op2)
{
    return (op1.val == op2.val);
}

public static bool operator !=(MyClass op1, MyClass op2)
{
    return !(op1 == op2);
}

public override bool Equals(object op1)
{
    return val == ((MyClass)op1).val;
}

 

 

 

 

_

반응형