Mono Class Library: System.Byte Overview | Members

System.Byte.ToString Method

Returns a string representation of the value of the current instance. [Edit]

public string ToString (string format)

Parameters

format
A string that specifies the format of the returned string.
Note: For a list of valid values, see byte.ToString(string, IFormatProvider ).
[Edit]

Returns

A string representation of the current instance formatted as specified by format. The string takes into account the current system culture. [Edit]

Exceptions

TypeReason
FormatExceptionformat is invalid. [Edit]

Remarks

This version of byte.ToString is equivalent to byte.ToString (format , null ).

If format is null , the general format specifier "G" is used.

[Edit]

Example

The following example demonstrates the byte.ToString method.

C# Example
using System;
public class ByteToStringExample {
   public static void Main() {
      Byte b = 8;
      Console.WriteLine(b);
      String[] formats = {"c", "d", "e", "f", "g", "n", "p", "x" };
      foreach(String str in formats)
         Console.WriteLine("{0}: {1}", str, b.ToString(str));
   }
}
   

The output is

8
c: $8.00
d: 8
e: 8.000000e+000
f: 8.00
g: 8
n: 8.00
p: 800.00 %
x: 8

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0