Table of Contents

Class IntBitExtensions

Namespace
FishMMO.Shared
Assembly
FishMMO-SharedUtility.dll

Extension methods for high-performance bitwise flag manipulation on integers. Supports both raw bit indices and generic Enum-based bit positions.

public static class IntBitExtensions
Inheritance
IntBitExtensions
Inherited Members

Methods

DisableBit(ref int, int)

Sets the specified bit to 0 (off) using a bitwise NOT and AND operation.

public static void DisableBit(this ref int flag, int bitPosition)

Parameters

flag int
bitPosition int

DisableBit<T>(ref int, T)

Sets the specified generic bit position to 0 (off).

public static void DisableBit<T>(this ref int flag, T bitPosition) where T : unmanaged, Enum

Parameters

flag int
bitPosition T

Type Parameters

T

EnableBit(ref int, int)

Sets the specified bit to 1 (on) using a bitwise OR operation.

public static void EnableBit(this ref int flag, int bitPosition)

Parameters

flag int
bitPosition int

EnableBit<T>(ref int, T)

Sets the specified generic bit position to 1 (on).

public static void EnableBit<T>(this ref int flag, T bitPosition) where T : unmanaged, Enum

Parameters

flag int
bitPosition T

Type Parameters

T

IsFlagged(int, int)

Checks if the specified bit position is set (1) in the integer value.

public static bool IsFlagged(this int flag, int bitPosition)

Parameters

flag int

The bitmask integer.

bitPosition int

The zero-based index of the bit (0-31).

Returns

bool

True if the bit is set; otherwise, false.

IsFlagged<T>(int, T)

Checks if the specified generic bit position is set. Use this for Enums representing bit indices.

public static bool IsFlagged<T>(this int flag, T bitPosition) where T : unmanaged, Enum

Parameters

flag int
bitPosition T

Returns

bool

Type Parameters

T

An enum type backed by int.

ToggleBit(ref int, int)

Reverses the state of the specified bit (1 becomes 0, 0 becomes 1).

public static void ToggleBit(this ref int flag, int bitPosition)

Parameters

flag int
bitPosition int

ToggleBit<T>(ref int, T)

Reverses the state of the specified generic bit position (1 becomes 0, 0 becomes 1).

public static void ToggleBit<T>(this ref int flag, T bitPosition) where T : unmanaged, Enum

Parameters

flag int
bitPosition T

Type Parameters

T