Top community members
All Wiki Articles Create Wiki Article

In the past we had a dream,
to have place where we could share IT knowledge,
to ask questions without fear that someone will judge us.

Now we are a group of people who make this dream come true. ❤ 💻

If you think sharing knowledge and helping other is valuable.

join our community - Click here

C#/.NET - convert byte to string

0 contributions
2 points

1. ToString example

byte value = 123;
string text = value.ToString(); // or 123.ToString()
Console.WriteLine(text); // 123

Output:

123

2. Convert.ToString example

byte value = 123;
string text = Convert.ToString(value);
Console.WriteLine(text); // 123

Output:

123

3. String.Format example

byte value = 123;
string text = string.Format("{0}", value);
Console.WriteLine(text); // 123

Output:

123

4. interpolation example

byte value = 123;
string text = $"{value}";
Console.WriteLine(text); // 123

Output:

123

Note: this feature available is in C# 6 and later versions 

5. summing string and number example (empty string)

byte value = 123;
string text = "" + value; 
// string text = value + "";
// string text = string.Empty + value;
// string text = value + string.Empty;
Console.WriteLine(text); // 123

Output:

123

6. StringBuilder example

byte value = 123;
string text = new StringBuilder().Append(value).ToString();
Console.WriteLine(text); // 123

Output:

123

7. TypeConverter.ConvertTo example

TypeConverter converter = TypeDescriptor.GetConverter(typeof(byte));

byte value = 123;
string text = (string)converter.ConvertTo(value, typeof(string));

Console.WriteLine(text); // 123

Output:

123
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more