2
\$\begingroup\$

Is it possible to write this method in a prettier way?

public static string ByteArrayToString(byte[] byteArray)
{
  var hex = new StringBuilder(byteArray.Length * 2);
  foreach (var b in byteArray)
    hex.AppendFormat("{0:x2}", b);
  return hex.ToString();
}
\$\endgroup\$

1 Answer 1

8
\$\begingroup\$

There are popular topics on StackOverflow that cover this exact question:

\$\endgroup\$
2
  • \$\begingroup\$ It seems that just as on StackOverflow, consensus here is that link-only answers aren't preferable. \$\endgroup\$ May 22, 2020 at 18:50
  • \$\begingroup\$ This answer refers to internal stackoverflow links, not external. Basically it says “this question has already been answered”. I don’t see any reason to copy/paste the code from similar answers. \$\endgroup\$
    – almaz
    May 23, 2020 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.