C# UInt16 ToString()

Description

UInt16 ToString() converts the numeric value of this instance to its equivalent string representation.

Syntax

UInt16.ToString() has the following syntax.


public override string ToString()

Returns

UInt16.ToString() method returns The string representation of the value of this instance, which consists of a sequence of digits ranging from 0 to 9, without a sign or leading zeros.

Example

The following example displays a UInt16 value by using the default ToString() method.


/* w  w  w  .  ja  v a  2s  .  c o  m*/
using System;

public class Example
{
   public static void Main()
   {
      ushort value = 16324;
      Console.WriteLine(value.ToString());      
      string[] formats = { "G", "C", "D", "F", "N", "X" };
      foreach (string format in formats)
         Console.WriteLine("{0} format specifier: {1,12}", 
                           format, value.ToString(format));         
   }
}

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