Ejemplo n.º 1
0
    // Overrides from Object
    public override bool Equals(object o)
    {
        // We only handle equality for objects of our type
        if (!(o is UnitInfo))
        {
            // Pass it to the base class
            return(base.Equals(o));
        }

        // Make a type correct reference
        UnitInfo other = o as UnitInfo;

        // Trivial inequality
        if (this.GetHashCode() != other.GetHashCode())
        {
            // Different hash codes means not equal
            return(false);
        }

        // Test in order of least to most complex, let short circuits work
        return(this.unitCost == other.unitCost &&
               this.unitName == other.unitName &&
               this.unitPreFab == other.unitPreFab);
    }