C# Convert ToUInt16(String, Int32)

Description

Convert ToUInt16(String, Int32) converts the string representation of a number in a specified base to an equivalent 16-bit unsigned integer.

Syntax

Convert.ToUInt16(String, Int32) has the following syntax.


[CLSCompliantAttribute(false)]/*w w  w .j a  v  a2 s . c  om*/
public static ushort ToUInt16(
  string value,
  int fromBase
)

Parameters

Convert.ToUInt16(String, Int32) has the following parameters.

  • value - A string that contains the number to convert.
  • fromBase - The base of the number in value, which must be 2, 8, 10, or 16.

Returns

Convert.ToUInt16(String, Int32) method returns A 16-bit unsigned integer that is equivalent to the number in value, or 0 (zero) if value is null.

Example


//from  ww  w .j av  a 2 s. c  o  m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    System.Console.WriteLine(Convert.ToUInt16("10" ,2));
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version