public static Word FromBytes(byte[] bytes) { byte[] wordValue; int frequency; int id; int posID; using (MemoryStream mem = new MemoryStream(bytes)) { using (BinaryReader br = new BinaryReader(mem)) { wordValue = br.ReadBytes(maxWordLength * sizeof(char)); frequency = br.ReadInt32(); id = br.ReadInt32(); posID = br.ReadInt32(); } } string value = stringFromFixedLengthByteArray(wordValue); Word w = new Word() { Frequency = frequency, Id = id, Value = value, PoS = PartOfSpeech.FromId(posID) }; return(w); }