Class HashCodeHelper
Borrowed from http://stackoverflow.com/a/2575444/694494
Inheritance
Namespace: Umbraco.Cms.Core
Assembly: Umbraco.Core.dll
Syntax
public static class HashCodeHelper
Methods
View SourceCombineHashCode<T>(int, T)
Alternative way to get a hashcode is to use a fluent
interface like this:
return 0.CombineHashCode(field1).CombineHashCode(field2).
CombineHashCode(field3);
Declaration
public static int CombineHashCode<T>(this int hashCode, T arg)
Parameters
| Type | Name | Description |
|---|---|---|
| int | hashCode | |
| T | arg |
Returns
| Type | Description |
|---|---|
| int |
Type Parameters
| Name | Description |
|---|---|
| T |
GetHashCodeForOrderNoMatterCollection<T>(IEnumerable<T>)
Gets a hashcode for a collection for that the order of items does not matter. So {1, 2, 3} and {3, 2, 1} will get same hash code.
Declaration
public static int GetHashCodeForOrderNoMatterCollection<T>(IEnumerable<T> list)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | list |
Returns
| Type | Description |
|---|---|
| int |
Type Parameters
| Name | Description |
|---|---|
| T |
GetHashCode<T>(IEnumerable<T>)
Gets a combined hash code for an enumerable collection of values.
Declaration
public static int GetHashCode<T>(IEnumerable<T> list)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | list | The collection of values. |
Returns
| Type | Description |
|---|---|
| int | A combined hash code. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the values. |
GetHashCode<T>(T[])
Gets a combined hash code for an array of values.
Declaration
public static int GetHashCode<T>(T[] list)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | list | The array of values. |
Returns
| Type | Description |
|---|---|
| int | A combined hash code. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the values. |
GetHashCode<T1, T2>(T1, T2)
Gets a combined hash code for two values.
Declaration
public static int GetHashCode<T1, T2>(T1 arg1, T2 arg2)
Parameters
| Type | Name | Description |
|---|---|---|
| T1 | arg1 | The first value. |
| T2 | arg2 | The second value. |
Returns
| Type | Description |
|---|---|
| int | A combined hash code. |
Type Parameters
| Name | Description |
|---|---|
| T1 | The type of the first value. |
| T2 | The type of the second value. |
GetHashCode<T1, T2, T3>(T1, T2, T3)
Gets a combined hash code for three values.
Declaration
public static int GetHashCode<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3)
Parameters
| Type | Name | Description |
|---|---|---|
| T1 | arg1 | The first value. |
| T2 | arg2 | The second value. |
| T3 | arg3 | The third value. |
Returns
| Type | Description |
|---|---|
| int | A combined hash code. |
Type Parameters
| Name | Description |
|---|---|
| T1 | The type of the first value. |
| T2 | The type of the second value. |
| T3 | The type of the third value. |
GetHashCode<T1, T2, T3, T4>(T1, T2, T3, T4)
Gets a combined hash code for four values.
Declaration
public static int GetHashCode<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
| Type | Name | Description |
|---|---|---|
| T1 | arg1 | The first value. |
| T2 | arg2 | The second value. |
| T3 | arg3 | The third value. |
| T4 | arg4 | The fourth value. |
Returns
| Type | Description |
|---|---|
| int | A combined hash code. |
Type Parameters
| Name | Description |
|---|---|
| T1 | The type of the first value. |
| T2 | The type of the second value. |
| T3 | The type of the third value. |
| T4 | The type of the fourth value. |