# ScriptId

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>
<span>Inherits <a href="https://learn.microsoft.com/dotnet/api/system.icomparable">IComparable</a>, <a href="https://learn.microsoft.com/dotnet/api/system.icomparable-1">IComparable&lt;ScriptId&gt;</a></span>
</div>

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

Encapsulates an Script Id.

```csharp
public struct ScriptId : IComparable, IComparable<ScriptId>
```

## Remarks

Script Ids are unique per running scene.

## Members at a glance

| Kind | Members |
|---|---|
| **Fields** | [AllScripts](#allscripts) · [Invalid](#invalid) |
| **Properties** | [IsValid](#isvalid) |
| **Methods** | [CompareTo](#compareto) · [Equals](#equals) · [GetHashCode](#gethashcode) · [ToString](#tostring) |
| **Operators** | [op\_Equality](#op_equality) · [op\_Implicit](#op_implicit) · [op\_Inequality](#op_inequality) |

## Fields

### AllScripts

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

```csharp signature
public static readonly ScriptId AllScripts
```

The invalid id script.

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

This value is used by certain APIs to represent all scripts.

</details>

</div>

### Invalid

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

```csharp signature
public static readonly ScriptId Invalid
```

The invalid id script.

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

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

</details>

</div>


## Properties

### IsValid

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

```csharp signature
public bool IsValid { get; }
```

Gets the valid state for this ScriptId.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — True if this id is a valid ScriptId.

</div>


## Methods

### CompareTo

<div class="api-card" id="compareto-scriptid">
<span id="M:Sansar.Script.ScriptId.CompareTo(Sansar.Script.ScriptId)"></span>

```csharp signature
public int CompareTo(ScriptId other)
```

Compares another instance to this scriptId.

| Parameter | Type | Description |
|---|---|---|
| `other` | [ScriptId](/scripting/api/sansar.script/scriptid) | The scriptId to compare with this instance. |

**Returns:** [int](https://learn.microsoft.com/dotnet/api/system.int32) — Returns -1 if this scriptId comes before the specified instance, 1 if this script id comes after the specified instance, 0 otherwise.

</div>

<div class="api-card" id="compareto-object">
<span id="M:Sansar.Script.ScriptId.CompareTo(System.Object)"></span>

```csharp signature
public int CompareTo(object other)
```

Compares another instance to this scriptId.

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

**Returns:** [int](https://learn.microsoft.com/dotnet/api/system.int32) — Returns -1 if this scriptId comes before the specified instance, 1 if this script id comes after the specified instance, 0 otherwise. Returns 2 if the object is not a scriptId.

</div>

### Equals

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

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

Value comparison for ScriptId.

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

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the argument is an ScriptId 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.ScriptId.GetHashCode"></span>
<span id="M:Sansar.Script.ScriptId.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.ScriptId.ToString"></span>
<span id="M:Sansar.Script.ScriptId.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 [`Script.ToString`](https://learn.microsoft.com/dotnet/api/system.script.tostring).

</details>

</div>


## Operators

### op_Equality

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

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

ScriptId equality operator.

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

**Returns:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — true if the ScriptIds 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.ScriptId.op_Implicit(Sansar.Script.ScriptId)~System.UInt32"></span>

```csharp signature
public static implicit operator uint(ScriptId id)
```

Convert a ScriptId to a uint.

| Parameter | Type | Description |
|---|---|---|
| `id` | [ScriptId](/scripting/api/sansar.script/scriptid) | The Script id to convert. |

</div>

### op_Inequality

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

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

ScriptId inequality operator.

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

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

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

This is a value comparison.

</details>

</div>


## Used in examples

- [SharedStopwatchExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/SharedStopwatchExample.cs)

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