I have an app that converts binary file into ASCII file. With profiler I found that I spend 25% of time doing Encoding.GetBytes() which is called from BinaryWriter.Write(wchar[]). It is completely correct since I have many constructs similar to this one:
m_writer.Write("some fancy long text".ToCharArray());
Do you have any smart idea how to avoid this encoding conversion?
I now that one idea would be to to do something similar to this:
const byte[] SOME_FANCY_LONG_TEXT = Encoding.ASCII.GetBytes("some fancy ...");
// ... and later
m_writer.Write(SOME_FANCY_LONG_TEXT);
but I have to many such entries to do it manually.