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();
}
Simon Forsberg
59.7k9 gold badges157 silver badges311 bronze badges
asked Nov 29, 2012 at 8:57
\$\endgroup\$

1 Answer 1

8
\$\begingroup\$

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

answered Nov 29, 2012 at 9:04
\$\endgroup\$
2
  • \$\begingroup\$ It seems that just as on StackOverflow, consensus here is that link-only answers aren't preferable. \$\endgroup\$ Commented 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\$ Commented May 23, 2020 at 19:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.