I am coding in C# and willing to use unsafe/fixed.
I would like to be able to convert from a byte[] to a string[]. I started with a file of strings (terminated by \n). I replaced all of the \n with \0 in the byte array that I read from the file. I thought I might now just reinterpret the byte[] as a string[] since the newlines are now \0s. I think that makes sense, but I could be wrong. If I recall from C++ (decades ago unfortunately) a string[] is just a char[][] where each inner char[] is null terminated. So, I think the code below could work if I could do the (fancycast).
// File contains strings on each line
byte[] bytes = ReadFile();
Replace(bytes, '\n', \0');
string[] strings = (fancycast)bytes
I don't know how to do the (fancycast). Thank you very much.
I know about all of the Streams and Readers in C# and I have specific reasons why I am not using them. Please don't suggest a different design. I would just like to reinterpret cast the array. Thank you for your help.