unsigned int Type Range Default Value unsigned int 0 to 4,294,967,295 0 The unsigned int type represents a 32-bit unsigned two's-complement integer. Integer types that are unsigned consist only of positive integers. Literals Integrals without a suffix are interpreted in this order: int, unsigned int, long, unsigned long, byte, signed byte, short, unsigned short, and char. If the integral value does not "fit" within any specified types, such as possible function overloads or a specified variable type, an error will be raised at compile time. There is no suffix for the unsigned int type, and integer literals that fit within the range of the unsigned int type can be written without a suffix. Auto-boxing All primitive types have a corresponding wrapper class. The corresponding wrapper class for the unsigned int type is System.UInteger32. Auto-boxing occurs when a value of a primitive type is assigned or passed as an argument to a variable or function that expects a value of its corresponding wrapper class. For example, the integer literal 4294967295 is interpreted as unsigned int and can be assigned to a variable of type System.UInteger32 via auto-boxing: 1System.UInteger32 value = 4294967295; // Auto-boxing Without auto-boxing, the equivalent code would be: 1System.UInteger32 value = new System.UInteger32(4294967295); The reverse also occurs. Unboxing is when the wrapper class is automatically converted to its corresponding primitive type. Thus, an instance of System.UInteger32 can be unboxed to the unsigned int primitive type. 1unsigned int value = new System.UInteger32(4294967295); // Unboxing Overflow and Wrapping When values for integer types go out of range at runtime, they will "wrap around". Thus, if a variable is declared as having the unsigned int type, and, at runtime, the variable's value exceeds the unsigned int maximum (4,294,967,295) by one, it will wrap around to the unsigned int minimum (0); if the value exceeds the unsigned int maximum by two, it will wrap around to the unsigned int minimum plus one (1); and so on. Conversions for Internal Types For conversions to and from the unsigned int type, consult the Conversions Table. Conversions for external Type When converting from external: If the external value is a numeric value, it will be automatically converted to the equivalent integer value. If the external value is a numeric value that is out of range, wrapping will occur. If the external value is a numeric string value, it will be automatically converted to the equivalent integer value. If the external value is a numeric string value that is out of range, wrapping will occur. If the external value is a non-numeric string value, it will be automatically converted to zero (0). If the external value is the Boolean true value, it will be automatically converted to one (1). If the external value is the Boolean false value, it will be automatically converted to zero (0). If the external value is a non-numeric value and non-Boolean value, it will be automatically converted to zero (0). When converting to external, the value will be converted to a JavaScript number value. See Also System.UInteger32 Conversions Table Auto-boxing and Unboxing Variable Declarations Function Declarations Share HTML | BBCode | Direct Link