# ComponentId

Kind: Struct · Namespace: Sansar.Script · Assembly: Sansar.Script.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-struct" data-pagefind-filter="kind:Struct">Struct</span>
<span data-pagefind-filter="namespace:Sansar.Script">Namespace <a href="/scripting/api/sansar.script"><code>Sansar.Script</code></a></span>
</div>

<span id="T:Sansar.Script.ComponentId"></span>

Encapsulates a Component Id.

```csharp
public struct ComponentId
```

## Remarks

The ComponentId is a unique identifier for a component. An [`ObjectId`](/scripting/api/sansar.script/objectid) can be derived from a ComponentId.

## Members at a glance

| Kind | Members |
|---|---|
| **Fields** | [Invalid](#invalid) |
| **Properties** | [ObjectId](#objectid) |
| **Methods** | [Equals](#equals) · [GetHashCode](#gethashcode) · [ToString](#tostring) |
| **Operators** | [op\_Equality](#op_equality) · [op\_Implicit](#op_implicit) · [op\_Inequality](#op_inequality) |

## Fields

### Invalid

<div class="api-card">
<span id="F:Sansar.Script.ComponentId.Invalid"></span>

```csharp signature
public static readonly ComponentId Invalid
```

The invalid id object.

<details class="api-remarks"><summary>Remarks</summary>

This value is used by certain APIs to represent an invalid ComponentId.

</details>

</div>


## Properties

### ObjectId

<div class="api-card">
<span id="P:Sansar.Script.ComponentId.ObjectId"></span>

```csharp signature
public ObjectId ObjectId { get; }
```

Retrieves the [`ObjectId`](/scripting/api/sansar.script/objectid) associated with this ComponentId.

**Value:** [ObjectId](/scripting/api/sansar.script/objectid) — The is exactly 1 ObjectId associated with each ComponentId.

<details class="api-remarks"><summary>Remarks</summary>

The ObjectId returned will be valid if the ComponentId is valid. An [`ComponentId.Invalid`](/scripting/api/sansar.script/componentid#invalid) ComponentId will return [`ObjectId.Invalid`](/scripting/api/sansar.script/objectid#invalid).

</details>

</div>


## Methods

### Equals

<div class="api-card">
<span id="M:Sansar.Script.ComponentId.Equals(System.Object)"></span>

```csharp signature
public override bool Equals(object obj)
```

Value comparison for ComponentId.

| Parameter | Type | Description |
|---|---|---|
| `obj` | [object](https://learn.microsoft.com/dotnet/api/system.object) | The object to compare. |

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the argument is a ComponentId and has the same value.

<details class="api-remarks"><summary>Remarks</summary>

This method overrides [`ValueType.Equals`](https://learn.microsoft.com/dotnet/api/system.valuetype.equals).

</details>

</div>

### GetHashCode

<div class="api-card">
<span id="M:Sansar.Script.ComponentId.GetHashCode"></span>
<span id="M:Sansar.Script.ComponentId.GetHashCode()"></span>

```csharp signature
public override int GetHashCode()
```

Retrieves the hash code for this instance.

**Returns:** [int](https://learn.microsoft.com/dotnet/api/system.int32) — The hash code for this instance.

<details class="api-remarks"><summary>Remarks</summary>

This method overrides [`ValueType.GetHashCode`](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode).

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Script.ComponentId.ToString"></span>
<span id="M:Sansar.Script.ComponentId.ToString()"></span>

```csharp signature
public override string ToString()
```

Converts the id to a hexadecimal string representation.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — The hexadecimal string representation.

<details class="api-remarks"><summary>Remarks</summary>

This method overrides [`Object.ToString`](https://learn.microsoft.com/dotnet/api/system.object.tostring).

</details>

</div>


## Operators

### op_Equality

<div class="api-card">
<span id="M:Sansar.Script.ComponentId.op_Equality(Sansar.Script.ComponentId,Sansar.Script.ComponentId)"></span>

```csharp signature
public static bool operator ==(ComponentId a, ComponentId b)
```

ComponentId equality operator.

| Parameter | Type | Description |
|---|---|---|
| `a` | [ComponentId](/scripting/api/sansar.script/componentid) | First ComponentId to compare. |
| `b` | [ComponentId](/scripting/api/sansar.script/componentid) | Second ComponentId to compare. |

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the ComponentIds have the same value.

<details class="api-remarks"><summary>Remarks</summary>

This is a value comparison.

</details>

</div>

### op_Implicit

<div class="api-card">
<span id="M:Sansar.Script.ComponentId.op_Implicit(System.UInt64)~Sansar.Script.ComponentId"></span>

```csharp signature
public static implicit operator ComponentId(ulong id)
```

Internal explicit conversion from a ulong.

| Parameter | Type | Description |
|---|---|---|
| `id` | [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) | A ulong representation of an ComponentId |

**Returns:** [ComponentId](/scripting/api/sansar.script/componentid) — A new ComponentId initialized with the given ulong.

<details class="api-remarks"><summary>Remarks</summary>

Internal.

</details>

</div>

### op_Inequality

<div class="api-card">
<span id="M:Sansar.Script.ComponentId.op_Inequality(Sansar.Script.ComponentId,Sansar.Script.ComponentId)"></span>

```csharp signature
public static bool operator !=(ComponentId a, ComponentId b)
```

ComponentId inequality operator.

| Parameter | Type | Description |
|---|---|---|
| `a` | [ComponentId](/scripting/api/sansar.script/componentid) | First ComponentId to compare. |
| `b` | [ComponentId](/scripting/api/sansar.script/componentid) | Second ComponentId to compare. |

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the ComponentIds have a different value.

<details class="api-remarks"><summary>Remarks</summary>

This is a value comparison.

</details>

</div>


## Used in examples

- [RandomMovement.cs](/scripting/examples/random-movement)
- [ObjectScriptExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ObjectScriptExample.cs)
- [SceneObjectScriptExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/SceneObjectScriptExample.cs)
- [ScriptLibrary/Quest/QuestObjectInteraction.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestObjectInteraction.cs)
- [ScriptLibrary/Quest/QuestVisibility.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Quest/QuestVisibility.cs)
- [ScriptLibrary/Scene/HintText.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/HintText.cs)
- [ScriptLibrary/Scene/Interaction.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Interaction.cs)
- [ScriptLibrary/Scene/PositionReset.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/PositionReset.cs)
- [ScriptLibrary/ScriptWatcher.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/ScriptWatcher.cs)

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>