TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
ushort keyword in C# is an alias for the .NET System.UInt16 structure. It represents a 16-bit (2-byte) unsigned integral value type used to store positive whole numbers and zero. Because it is unsigned, it cannot represent negative values, allocating all 16 bits strictly to the magnitude of the number.
Technical Specifications
- Underlying Type:
System.UInt16 - Memory Size: 16 bits (2 bytes)
- Value Range:
0to65,535() - Default Value:
0 - CLS Compliance:
ushortis not Common Language Specification (CLS) compliant.
Syntax and Initialization
C# does not have a dedicated literal suffix for theushort type. Integer literals are treated as int by default, but the compiler will implicitly convert an int literal to a ushort during assignment if the value falls within the valid 16-bit unsigned range.
Type Conversions
Implicit Conversions Aushort can be implicitly converted to any numeric type that has a larger memory footprint or can accommodate its maximum value without data loss. Valid implicit conversion targets are: int, uint, long, ulong, float, double, and decimal.
ushort from a larger integral type (e.g., int), a floating-point type, or a signed type (e.g., short) requires an explicit cast. This is enforced by the compiler because the source value might exceed the ushort upper bound of 65,535 or be less than 0. Depending on the execution context (checked vs. unchecked), invalid conversions will either throw an OverflowException or result in silent bitwise truncation.
Master C# with Deep Grasping Methodology!Learn More





