Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ToUInt64< TEnum >()

static ulong System.Enum.ToUInt64< TEnum > ( TEnum value)
inlinestaticprivate
Type Constraints
TEnum :struct 
TEnum :Enum 

Definition at line 258 of file Enum.cs.

258 : struct, Enum
259 {
260 return Type.GetTypeCode(typeof(TEnum)) switch
261 {
262 TypeCode.SByte => (ulong)Unsafe.As<TEnum, sbyte>(ref value),
263 TypeCode.Byte => Unsafe.As<TEnum, byte>(ref value),
264 TypeCode.Boolean => (ulong)(Unsafe.As<TEnum, bool>(ref value) ? 1 : 0),
265 TypeCode.Int16 => (ulong)Unsafe.As<TEnum, short>(ref value),
266 TypeCode.UInt16 => Unsafe.As<TEnum, ushort>(ref value),
267 TypeCode.Char => Unsafe.As<TEnum, char>(ref value),
268 TypeCode.UInt32 => Unsafe.As<TEnum, uint>(ref value),
269 TypeCode.Int32 => (ulong)Unsafe.As<TEnum, int>(ref value),
270 TypeCode.UInt64 => Unsafe.As<TEnum, ulong>(ref value),
271 TypeCode.Int64 => (ulong)Unsafe.As<TEnum, long>(ref value),
272 _ => throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType),
273 };
274 }

References System.Type.GetTypeCode(), System.SR.InvalidOperation_UnknownEnumType, and System.value.