Skip to content

Instantly share code, notes, and snippets.

@ArisAgnew
Created April 4, 2021 11:27
Show Gist options
  • Save ArisAgnew/283b8d427a5e7aa0b51630d97894884d to your computer and use it in GitHub Desktop.
Save ArisAgnew/283b8d427a5e7aa0b51630d97894884d to your computer and use it in GitHub Desktop.
EqualsExampleToRight
public Rect(decimal x, decimal y, decimal width, decimal height)
{
X = x;
Y = y;
Width = width;
Height = height;
}
/// <summary>
/// The x coordinate of the element in pixels.
/// </summary>
public decimal X { get; set; }
/// <summary>
/// The y coordinate of the element in pixels.
/// </summary>
public decimal Y { get; set; }
/// <summary>
/// The width of the element in pixels.
/// </summary>
public decimal Width { get; set; }
/// <summary>
/// The height of the element in pixels.
/// </summary>
public decimal Height { get; set; }
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
return Equals((Rect)obj);
}
/// <summary>
/// Determines whether the specified <see cref="Rect"/> is equal to the current <see cref="Rect"/>.
/// </summary>
/// <param name="other">The <see cref="Rect"/> to compare with the current <see cref="Rect"/>.</param>
/// <returns><c>true</c> if the specified <see cref="Rect"/> is equal to the current
/// <see cref="Rect"/>; otherwise, <c>false</c>.</returns>
public bool Equals(Rect other)
=> other != null &&
other.X == X &&
other.Y == Y &&
other.Height == Height &&
other.Width == Width;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment