c# - BinaryWriter problem - "code adds some byte between Write() method" -


I'm trying to use some code BinaryWriter and then BinaryReader. When I want to write I use method () but the problem is that there is a new byte between the two types of writing method which is in the ASCII table in decimal 31 (some 24). You can see it on this image:

Enter image details here

You can see that the byte ASCII decimal value is 31 by index 4 (5th byte). I did not include him there . As you can see that 1 4 bytes are reserved for a number (int 32), the next is the other data (mostly some text - it is no longer important).

As you can see from the code I type: 1 in the row - 10 in the line text "This is some text ..."

How come Is that between 5th byte (31st December) ??

And this is the code I got:

  Fixed zero main (string [] args) Send {// ///// - Receive: // sending data (); Console.ReadLine (); } Private Static void SendingData () {int [] commandNumbers = {1, 5, 10}; // is for 10 users (when they send some text)! For (int i = 0; i  New {value = A, Index = B})) {if (b.Index == 0) // First number value A = BitConverter ToInt32 (B. Well, 0); Else // Other text {foreach (byte_bite in b.Value) sb.Append (Convert.ToChar (_byte)); }} If (sb.ToString (). Length == 0) sb.Append ("Command Only"); Console.light line ("command = {0} and text \" {1} \ "., Value A, SB ToString ()); }} Private Stable IEnumerable & lt; Byte [] & gt; GateData (Byte [Data]) {(MemoryStream MS = New MemoryStream (Data)) (Byrider BR = New Binary Reader (MS)) {int j = 0; Byte [] buffer = new byte [4]; For (int i = 0; i & lt; data; langti; i ++) {buffer [j ++] = data [i]; If (I == 3) // sending the commanding data {yield returns buffer; Buffer = new byte [1]; J = 0; } And if sending (i> 3) // text {yield returns buffer; J = 0; }}}}}}    

If you look at, you will see that If you type a length-prefixed string 31 then your string has the number of characters - absolutely normal.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -