System.Convert.ToUInt16 C# (CSharp) Method

ToUInt16() private method

private ToUInt16 ( String value, int fromBase ) : ushort
value String
fromBase int
return ushort
            public static ushort ToUInt16 (String value, int fromBase) {
            if (fromBase!=2 && fromBase!=8 && fromBase!=10 && fromBase!=16) {
                throw new ArgumentException(Environment.GetResourceString("Arg_InvalidBase"));
            }
            int r = ParseNumbers.StringToInt(value,fromBase,ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned);
            if (r < UInt16.MinValue || r > UInt16.MaxValue)
                throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"));
            return (ushort) r;
        }

Same methods

Convert::ToUInt16 ( DateTime value ) : ushort
Convert::ToUInt16 ( String value ) : ushort
Convert::ToUInt16 ( String value, IFormatProvider provider ) : ushort
Convert::ToUInt16 ( bool value ) : ushort
Convert::ToUInt16 ( byte value ) : ushort
Convert::ToUInt16 ( char value ) : ushort
Convert::ToUInt16 ( decimal value ) : ushort
Convert::ToUInt16 ( double value ) : ushort
Convert::ToUInt16 ( float value ) : ushort
Convert::ToUInt16 ( int value ) : ushort
Convert::ToUInt16 ( long value ) : ushort
Convert::ToUInt16 ( object value ) : ushort
Convert::ToUInt16 ( object value, IFormatProvider provider ) : ushort
Convert::ToUInt16 ( sbyte value ) : ushort
Convert::ToUInt16 ( short value ) : ushort
Convert::ToUInt16 ( uint value ) : ushort
Convert::ToUInt16 ( ulong value ) : ushort
Convert::ToUInt16 ( ushort value ) : ushort

Usage Example

        public ushort ToUInt16(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(SConvert.ToUInt16(value, CultureInfo.InvariantCulture));
        }
All Usage Examples Of System.Convert::ToUInt16