Bitmask


Declaration

[Serializable]
public struct Bitmask : IEquatable<Bitmask>, IEquatable<int>

Description

A bitmask representation that can be used for bitwise operations. A bitmask is a set of bits that can be set or cleared.

Constructors

BitmaskCreates a new Bitmask from the given 32-bit integer.

Methods

HasFlagChecks if the bitmask contains the flag. (mask & flag) == flag
HasAnyFlagChecks if the bitmask contains any of the flags. (mask & flags) != 0
HasOnlyFlagsChecks if the bitmask contains only the given flags and no other flags. ((mask ^ flags) & flags) == 0
HasChecks if the nth bit of the bitmask is set.
GetReturns the nth bit of the bitmask.
SetSets the nth bit of the bitmask to 1.
ClearSets the nth bit of the bitmask to 0.
ToggleToggles the nth bit of the bitmask.
ChangeSets the nth bit of the bitmask to x.
EqualsDetermines if the bitmask is equal to another bitmask.
GetHashCodeReturns the hash code of the bitmask.
ToStringConverts the bitmask to a string.

Operators

EqualityDetermines if two bitmasks are equal.
InequalityDetermines if two bitmasks are not equal.
BitwiseAndPerforms a bitwise AND operation on two bitmasks.
BitwiseOrPerforms a bitwise OR operation on two bitmasks.
ExclusiveOrPerforms a bitwise XOR operation on two bitmasks.
OnesComplementPerforms a bitwise ones' complement operation on a bitmask.
LeftShiftPerforms a binary left shift operation on two bitmasks.
RightShiftPerforms a binary right shift operation on two bitmasks.
ImplicitImplicitly converts a bitmask to an integer.