Table of Contents

Class CHandle<T>

Namespace
CounterStrikeSharp.API.Modules.Utils
Assembly
CounterStrikeSharp.API.dll

CHandle is a class that represents a 32-bit ID (entindex + serial number) unique to every past and present entity in a game. It is used to refer to entities where pointers and entity indexes are unsafe; mainly across the client/server divide. More info

public class CHandle<T> : IEquatable<CHandle<T>> where T : NativeEntity

Type Parameters

T

Type of entity this handle refers to

Inheritance
CHandle<T>
Implements
Derived

Constructors

CHandle(nint)

public CHandle(nint raw)

Parameters

raw nint

CHandle(uint)

public CHandle(uint raw)

Parameters

raw uint

Properties

Index

public uint Index { get; }

Property Value

uint

IsValid

Checks that the handle is valid and points to an entity.

public bool IsValid { get; }

Property Value

bool

Raw

public uint Raw { get; set; }

Property Value

uint

SerialNum

public uint SerialNum { get; }

Property Value

uint

Value

Retrieves the instance of the entity this handle refers to.

public T? Value { get; }

Property Value

T

Methods

Equals(CHandle<T>?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CHandle<T>? other)

Parameters

other CHandle<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

Get()

Retrieves the instance of the entity this handle refers to.

public T? Get()

Returns

T

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

implicit operator uint(CHandle<T>)

public static implicit operator uint(CHandle<T> handle)

Parameters

handle CHandle<T>

Returns

uint