c# - How to store a length prefixed string -


I have a program that receives network packets that are binary serials, I currently have data directly from the byte array directly There is a way to store stores through using pointers. But what I want now is that there is a way to store the utf string in strat, while still keeping the easy method of copying the byte array. The string is considered prefixed with length sign in an unsigned short string bytes. Does it store internally four (or) stars in C #, or do I need to make it my own?

My current straight layout is like this:

  public structure generic packet {public less packet; Public static generic packet ReadUsingPointer (byte [] data) {insecure {fixed (byte * packet = and data [0]) {return * (generic packet *) packet; }}}}   

Read using the pointer takes just one byte array and gives it an indicator but as a generic stront. It works for every common type, but the strings are more complex.

Thanks for any thoughts!

This will work on a BSTR and BSTR methods (available in the Win32 and Win32 Compatibility libraries) - if Your prefix refers to bytes, not the character count, because the characters can be many bytes; BSTR does not know about any of these

C-string does not end with a prefix, C ++ and C # string uses implementation-defined storage, although they generally have an array with a different length parameter They are definitely not BSTRs.

Comments