Triangle2D GetHashCode Method Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D.Shapes
Assembly: DeltaEngine.Rendering2D.Shapes (in DeltaEngine.Rendering2D.Shapes.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public override int GetHashCode()

Return Value

Type: Int32
Remarks

Tests: DeltaEngine.Rendering2D.Shapes.Tests.Triangle2DTests
Examples

1 unit tests call DeltaEngine.Rendering2D.Shapes.Triangle2D.GetHashCode
[Test]
public void GetHashCodeViaDictionary()
{
    var triangle1 = new Triangle2D(new Vector2D(1, 2), new Vector2D(3, 4), new Vector2D(5, 6));
    var triangle1Similar = new Triangle2D(new Vector2D(1, 2), new Vector2D(3, 4),
        new Vector2D(15, 16));
    var triangle2 = new Triangle2D(new Vector2D(11, 12), new Vector2D(13, 14),
        new Vector2D(15, 16));
    var triangles = new Dictionary<Triangle2D, int> { { triangle1, 1 }, { triangle2, 2 } };
    Assert.IsTrue(triangles.ContainsKey(triangle1));
    Assert.IsTrue(triangles.ContainsKey(triangle2));
    Assert.IsFalse(
        triangles.ContainsKey(new Triangle2D(new Vector2D(1, 2), new Vector2D(3, 4),
            new Vector2D(5, 7))));
    Assert.AreNotEqual(triangle1.GetHashCode(), triangle1Similar.GetHashCode());
}
See Also