private static ulong ToUInt64(object value) { switch (Convert.GetTypeCode(value)) { case TypeCode.Boolean: case TypeCode.Char: case TypeCode.Byte: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: return(Convert.ToUInt64(value, CultureInfo.InvariantCulture)); case TypeCode.SByte: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: return(unchecked ((ulong)Convert.ToInt64(value, CultureInfo.InvariantCulture))); default: throw CodeExceptions.UnexpectedArgumentValue(nameof(value), value); } }