Format byte to string to string using the standard format in CSharp

Description

The following code shows how to format byte to string to string using the standard format.

Example


//from   ww w .  jav  a2 s.c  o m
using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      sbyte[] values = { -1, 0, 1 };
      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));
         }
      }
   }
}




















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var