C# SByte ToString(String)

Description

SByte ToString(String) converts the numeric value of this instance to its equivalent string representation, using the specified format.

Syntax

SByte.ToString(String) has the following syntax.


public string ToString(
  string format
)

Parameters

SByte.ToString(String) has the following parameters.

  • format - A standard or custom numeric format string.

Returns

SByte.ToString(String) method returns The string representation of the value of this instance as specified by format.

Example

The following example initializes an array of SByte values and displays them by using each standard format string and some custom format strings.


using System;//  w  ww  . j  a  v a 2 s . c o m
using System.Globalization;

public class Example
{
   public static void Main()
   {
      sbyte[] values = { -123, 0, 123 };
      string[] specifiers = { "G", "C", "D3", "E2", "e3", "F", 
                              "N", "P", "X", "00.0", "#.0", 
                              "000;(0);**Zero**" };

      foreach (sbyte value in values)
      {
         foreach (string specifier in specifiers)
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier));
         Console.WriteLine();
      }
   }
}

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