In C#, UInt16 struct is used to represent 16-bit unsigned integers(also termed as ushort data type) starting from range 0 to 65535. It provides different types of method to perform various actions like to compare instances of this type, convert the value of an instance to its string representation, convert the string representation of a number to an instance of this type, etc. This struct is defined under System namespace. UInt16 struct inherits the ValueType class which inherits the Object class.
|MaxValue||Represents the largest possible value of UInt16. This field is constant.|
|MinValue||Represents the smallest possible value of UInt16. This field is constant.|
|CompareTo()||Compares the current instance to a specified object or UInt16 and returns an indication of their relative values.|
|Equals()||Returns a value which shows whether the current instance is equal to a specified object or UInt16.|
|GetHashCode()||Returns the hash code for this instance.|
|GetTypeCode()||Returns the TypeCode for value type UInt16.|
|Parse()||Converts the string representation of a number to its 16-bit unsigned integer equivalent.|
|ToString()||Converts the numeric value of this instance to its equivalent string representation.|
|TryParse()||Converts the string representation of a number to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed.|
The hash code of myval is: 545
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.