John Lam [mailto:[EMAIL PROTECTED]] wrote:
> With short strings, it does write out the length as a single > byte. With longer strings, it does expand it to a word. Now, > when reading this thing back in, how does one determine > whether the length prefix is one or two bytes???? John, While I don't have time to totally dissect it right this second, I whipped out ILDASM and looked at BinaryReader::GetString and it defers to a protected method called BinaryReader::Read7BitEncodedInt which seems to use BinaryReader::ReadInt in two different forms to figure out if it should read it as a byte or a word. Like I said I don't have time to dissect the algorithm they use to know when it's a word vs. a byte, but hopefully this will send you down the right path. HTH, Drew You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.