Struct Pair<T1, T2>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
A lightweight generic representation of a pair of items.
public readonly struct Pair<T1, T2> : IEquatable<Pair<T1, T2>>
Type Parameters
T1
First item type.
T2
Second item type.
- Implements
-
IEquatable<Pair<T1, T2>>
- Inherited Members
- Extension Methods
Constructors
Pair(T1, T2)
Creates a new Pair<T1, T2> instance.
public Pair(T1 first, T2 second)
Parameters
first
T1First item.
second
T2Second item.
Fields
First
First item.
public readonly T1 First
Field Value
- T1
Second
Second item.
public readonly T2 Second
Field Value
- T2
Methods
Equals(Pair<T1, T2>)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(Pair<T1, T2> other)
Parameters
other
Pair<T1, T2>An object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
[Pure]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
SetFirst<T>(T)
Creates a new Pair<T1, T2> instance with changed First item.
[Pure]
public Pair<T, T2> SetFirst<T>(T first)
Parameters
first
TFirst item.
Returns
- Pair<T, T2>
New Pair<T1, T2> instance with unchanged Second item.
Type Parameters
T
First item type.
SetSecond<T>(T)
Creates a new Pair<T1, T2> instance with changed Second item.
[Pure]
public Pair<T1, T> SetSecond<T>(T second)
Parameters
second
TSecond item.
Returns
- Pair<T1, T>
New Pair<T1, T2> instance with unchanged First item.
Type Parameters
T
Second item type.
ToString()
Returns a string representation of this Pair<T1, T2> instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
Operators
operator ==(Pair<T1, T2>, Pair<T1, T2>)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(Pair<T1, T2> a, Pair<T1, T2> b)
Parameters
Returns
- bool
true when operands are equal, otherwise false.
operator !=(Pair<T1, T2>, Pair<T1, T2>)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(Pair<T1, T2> a, Pair<T1, T2> b)
Parameters
Returns
- bool
true when operands are not equal, otherwise false.