fromString Summary Converts a string to an unsigned short value. Usage public static unsigned short fromString(string numberAsStr) Returns The unsigned short equivalent of the string value or zero (0) if the string is not a numeric value. Parameters numberAsStr The string value to convert. Description Converts a string to an unsigned short value. import System; unsigned short x = UInteger16.fromString("100"); Console.log(x); // 100 If the string being converted is not a valid integer value, zero (0) is returned. import System; unsigned short x = UInteger16.fromString("abc"); Console.log(x); // 0 If the string being converted is numeric but does not fit into the unsigned short data range [ 0, 65535 ] (inclusive), the value will be wrapped: if the value exceeds the unsigned short maximum (65,535) by one, it will wrap around to the unsigned short minimum (0); if the value exceeds the unsigned short maximum by two, it will wrap around to the unsigned short minimum plus one (1); and so on. import System; unsigned short exceedByOne = UInteger16.fromString("65536"); Console.log(exceedByOne); // 0 unsigned short exceedByTwo = UInteger16.fromString("65537"); Console.log(exceedByTwo); // 1 unsigned short exceedByThree = UInteger16.fromString("65538"); Console.log(exceedByThree); // 2 Examples Basic Usage 1234import System; unsigned short x = UInteger16.fromString("100");Console.log(x); // 100 Share HTML | BBCode | Direct Link