Struct Point<T>
Represents a point in a two-dimensional coordinate system
public readonly struct Point<T> : IEquatable<Point<T>>, ISpanFormattable, IFormattable, IEqualityOperators<Point<T>, Point<T>, bool> where T : unmanaged, IEquatable<T>, IFormattable, ISpanFormattable, IEqualityOperators<T, T, bool>
Type Parameters
TThe type of the coordinates
- Implements
-
IEquatable<Point<T>>
- Inherited Members
Constructors
Point(in T, in T)
Represents a point in a two-dimensional coordinate system
[SetsRequiredMembers]
public Point(in T x, in T y)
Parameters
xTThe X coordinate of the point
yTThe Y coordinate of the point
Properties
X
Gets or initializes the X coordinate of the point
public required T X { get; init; }
Property Value
- T
The X coordinate of the point
Y
Gets or initializes the Y coordinate of the point
public required T Y { get; init; }
Property Value
- T
The Y coordinate of the point
Methods
Deconstruct(out T, out T)
Deconstructs the point into its X and Y coordinates
public void Deconstruct(out T x, out T y)
Parameters
xTThe X coordinate of the point
yTThe Y coordinate of the point
Equals(in Point<T>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(in Point<T> other)
Parameters
otherPoint<T>An object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(IFormatProvider? formatProvider)
Parameters
formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
ToString(string?)
Formats the value of the current instance using the specified format.
public string ToString(string? format)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.
Returns
- string
The value of the current instance in the specified format.
ToString(string?, IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of the current instance into the provided span of characters.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)
Parameters
destinationSpan<char>The span in which to write this instance's value formatted as a span of characters.
charsWrittenintWhen this method returns, contains the number of characters that were written in
destination.formatReadOnlySpan<char>A span containing the characters that represent a standard or custom format string that defines the acceptable format for
destination.providerIFormatProviderAn optional object that supplies culture-specific formatting information for
destination.
Returns
Operators
operator ==(in Point<T>, in Point<T>)
Compares two values to determine equality.
public static bool operator ==(in Point<T> left, in Point<T> right)
Parameters
Returns
implicit operator (T X, T Y)(in Point<T>)
Converts a Point<T> to a tuple of (X, Y)
public static implicit operator (T X, T Y)(in Point<T> point)
Parameters
pointPoint<T>The point to convert
Returns
implicit operator Point<T>(in (T X, T Y))
Converts a tuple of (X, Y) to a Point<T>
public static implicit operator Point<T>(in (T X, T Y) xy)
Parameters
Returns
- Point<T>
operator !=(in Point<T>, in Point<T>)
Compares two values to determine inequality.
public static bool operator !=(in Point<T> left, in Point<T> right)