# GetHashCode

> Generates a hash for a given component instance

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## GetHashCode\<T>(T)

Generates a hash for a given component instance

```csharp
public static int GetHashCode<T>(ref T val) where T : struct
```

### Parameters

**** (T): Component instance to hash

### Returns

| Type                                                       | Description                          |
| ---------------------------------------------------------- | ------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Returns true if the types are equal. |

## GetHashCode(void\*, TypeIndex)

Generates a hash for a given component instance

```csharp
public static int GetHashCode(void* val, TypeIndex typeIndex)
```

### Parameters

**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): Pointer to component instance to hash**** (\[TypeIndex]\(/engine/7000.0/script-reference/unity/entities/typeindex)): TypeIndex for the component

### Returns

| Type                                                       | Description                          |
| ---------------------------------------------------------- | ------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Returns true if the types are equal. |

## GetHashCode(Object, TypeIndex)

Generates a hash for a given component instance

```csharp
public static int GetHashCode(object val, TypeIndex typeIndex)
```

### Parameters

**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): Component instance to hash**** (\[TypeIndex]\(/engine/7000.0/script-reference/unity/entities/typeindex)): TypeIndex for the component

### Returns

| Type                                                       | Description                          |
| ---------------------------------------------------------- | ------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Returns true if the types are equal. |
