You can store strings as byte arrays, and then convert them to char
arrays or string
s as needed.
Simply use the ASCIIEnconding
class in the System.Text
namespace. The relevant methods would be:
char[] GetChars(byte[] bytes);
string GetString(byte[] bytes);
Of course char
and string
are UTF-16 so your not really gaining much as you'll eventually pay the memory "price" your trying to avoid; be it in the executable size or in runtime memory.
Bottom line, I'm not really sure why you'd want to do this, it seems pointless specially in a managed environment; if you are at this level of resource optimization your probably better off in a completely different environment.