short num = -32768; string str = num.ToString(); Console.WriteLine(str); // Output: "-32768"
short num = 255; string str = num.ToString("X"); Console.WriteLine(str); // Output: "FF"In this example, the Int16 value 255 is converted to its hexadecimal string representation using the ToString method with the "X" format specifier. This method is included in the .NET Framework class library, which is a part of the System namespace.