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.