Say I have a byte array with 100,000 bytes in it. I want to convert each byte into its textual representation of itself. For example:
byte[] b = new byte[55000];
for(int i = 0; i < b.Length; i++)
{
Console.WriteLine(ConvertToString(b[i]));
}
The above code takes around 35 seconds to complete, is there some way I could cut that down to around 5 seconds?
As mentioned in my comment I would suggest removing the
Console.WriteLine()method. I would also suggest that it be avoided in loops. Typically if you want to see what is being processed you would use either theDebug.WriteLine()(MSDN) or set a breakpoint (even a conditional breakpoint if you have a specific case that isn’t working right). If you need to return the data then again i would suggest using a string builder: