System.Enum.InternalFormattedHexString C# (CSharp) Method

InternalFormattedHexString() private static method

private static InternalFormattedHexString ( Object value ) : String
value Object
return String
        private static String InternalFormattedHexString(Object value)
        {
            TypeCode typeCode = Convert.GetTypeCode(value);

            switch (typeCode)
            {
                case TypeCode.SByte :
                    {
                        Byte result = (byte)(sbyte)value;

                        return result.ToString("X2", null);
                    }

                case TypeCode.Byte :
                    {
                        Byte result = (byte)value;

                        return result.ToString("X2", null);
                    }

                case TypeCode.Int16 :
                    {
                        UInt16 result = (UInt16)(Int16)value;

                        return result.ToString("X4", null);
                    }

                case TypeCode.UInt16 :
                    {
                        UInt16 result = (UInt16)value;

                        return result.ToString("X4", null);
                    }

                case TypeCode.UInt32 :
                    {
                        UInt32 result = (UInt32)value;

                        return result.ToString("X8", null);
                    }

                case TypeCode.Int32 :
                    {
                        UInt32 result = (UInt32)(int)value;

                        return result.ToString("X8", null);
                    }

                case TypeCode.UInt64 :
                    {
                        UInt64 result = (UInt64)value;

                        return result.ToString("X16", null);
                    }

                case TypeCode.Int64 :
                    {
                        UInt64 result = (UInt64)(Int64)value;

                        return result.ToString("X16", null);
                    }

                // All unsigned types will be directly cast
                default :
                    BCLDebug.Assert(false, "Invalid Object type in Format");
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType"));
            }
        }