Convert byte to string with culture-specific format in CSharp
Description
The following code shows how to convert byte to string with culture-specific format.
Example
/*from www . j av a 2s .c om*/
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NegativeSign = "~";
sbyte[] bytes = { -122, 17, 124 };
foreach (sbyte value in bytes){
Console.WriteLine(value.ToString(nfi));
}
Console.WriteLine("Using the invariant culture:");
foreach (sbyte value in bytes){
Console.WriteLine(value.ToString(NumberFormatInfo.InvariantInfo));
}
}
}
The code above generates the following result.