Show / Hide Table of Contents

# Struct AffinityKey

Optional wrapper for cache keys to provide support for custom affinity mapping. The value returned by Affinity will be used for key-to-node affinity.

##### Implements

System.IEquatable<AffinityKey>

##### Inherited Members

System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()

###### Namespace: Apache.Ignite.Core.Cache.Affinity

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public struct AffinityKey : IEquatable<AffinityKey>, IBinaryWriteAware

### Constructors

#### AffinityKey(Object)

Initializes a new instance of the AffinityKey struct.

##### Declaration

    public AffinityKey(object key)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object | key | The key.

#### AffinityKey(Object, Object)

Initializes a new instance of the AffinityKey struct.

##### Declaration

    public AffinityKey(object key, object affinity)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object | key | The key.
System.Object | affinity | The affinity key.

### Properties

#### Affinity

Gets the affinity key.

##### Declaration

    public object Affinity { get; }

##### Property Value

Type | Description
--- | ---
System.Object |

#### Key

Gets the key.

##### Declaration

    public object Key { get; }

##### Property Value

Type | Description
--- | ---
System.Object |

### Methods

#### Equals(AffinityKey)

Indicates whether the current object is equal to another object of the same type.

##### Declaration

    public bool Equals(AffinityKey other)

##### Parameters

Type | Name | Description
--- | --- | ---
AffinityKey | other | An object to compare with this object.

##### Returns

Type | Description
--- | ---
System.Boolean | true if the current object is equal to the `other` parameter; otherwise, false.

#### Equals(Object)

Determines whether the specified System.Object, is equal to this instance.

##### Declaration

    public override bool Equals(object obj)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object | obj | The System.Object to compare with this instance.

##### Returns

Type | Description
--- | ---
System.Boolean | `true` if the specified System.Object is equal to this instance; otherwise, `false`.

##### Overrides

System.ValueType.Equals(System.Object)

#### GetHashCode()

Returns a hash code for this instance.

##### Declaration

    public override int GetHashCode()

##### Returns

Type | Description
--- | ---
System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

##### Overrides

System.ValueType.GetHashCode()

#### ToString()

Returns a System.String that represents this instance.

##### Declaration

    public override string ToString()

##### Returns

Type | Description
--- | ---
System.String | A System.String that represents this instance.

##### Overrides

System.ValueType.ToString()

#### WriteBinary(IBinaryWriter)

Writes this object to the given writer.

##### Declaration

    public void WriteBinary(IBinaryWriter writer)

##### Parameters

Type | Name | Description
--- | --- | ---
IBinaryWriter | writer | Writer.

### Operators

#### Equality(AffinityKey, AffinityKey)

Implements the operator ==.

##### Declaration

    public static bool operator ==(AffinityKey left, AffinityKey right)

##### Parameters

Type | Name | Description
--- | --- | ---
AffinityKey | left | The left.
AffinityKey | right | The right.

##### Returns

Type | Description
--- | ---
System.Boolean | The result of the operator.

#### Inequality(AffinityKey, AffinityKey)

Implements the operator !=.

##### Declaration

    public static bool operator !=(AffinityKey left, AffinityKey right)

##### Parameters

Type | Name | Description
--- | --- | ---
AffinityKey | left | The left.
AffinityKey | right | The right.

##### Returns

Type | Description
--- | ---
System.Boolean | The result of the operator.

### Implements

System.IEquatable<T>