# HasComponent

> Reports whether the specified Entity instance still refers to a valid entity and that it has a component of type T.

## Definition

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

## HasComponent(Entity)

Reports whether the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) instance still refers to a valid entity and that it has a component of type T.

```csharp
public bool HasComponent(Entity entity)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity.

### Returns

| Type                                                          | Description                                                                                                                                                    |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the entity has a component of type T, and false if it does not. Also returns false if the Entity instance refers to an entity that has been destroyed. |

## HasComponent(Entity, bool)

Reports whether the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) instance still refers to a valid entity and that it has a component of type T.

```csharp
public bool HasComponent(Entity entity, out bool entityExists)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Denotes whether the given entity exists. Use to differentiate an invalid entity from the entity not having the given buffer.

### Returns

| Type                                                          | Description                                                                                                                                                    |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the entity has a component of type T, and false if it does not. Also returns false if the Entity instance refers to an entity that has been destroyed. |

## HasComponent(SystemHandle)

Reports whether the specified [SystemHandle](/engine/7000.0/script-reference/unity/entities/systemhandle.md) associated [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) is valid and contains a component of type T.

```csharp
public bool HasComponent(SystemHandle system)
```

### Parameters

**** (\[SystemHandle]\(/engine/7000.0/script-reference/unity/entities/systemhandle)): The system handle.

### Returns

| Type                                                          | Description                                                                                                                                                                            |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the entity associated with the system has a component of type T, and false if it does not. Also returns false if the system handle refers to a system that has been destroyed. |
