
Originally Posted by
abuckau907
Looks cool. You mind answering a question? How many bytes get sent in that example? "Elio" + "52" + bool, so maybe like 5 + 4 + 1 bytes or?

Originally Posted by
ლ(ಠ_ಠლ)
String.Length + Size of int + size of bool. Which in our case is: 4+32+1=37.
Euhm,. not realy,.
Code:
Console.WriteLine(data.Length);
This gives me '188' as output, why? because you used:
Code:
BinaryFormatter.Serialize(Stream, object);
Which insn't bad ofcourse, but just a little differend, it gave me this as output: (in sbytes)
Code:
0 1 0 0 0 255 255 255 255 1 0 0 0 0 0 0 0 12 2 0 0 0 74 67 111 110 115 111 108 101 65 112 112 108 105 99 97 116 105 111 110 49 44 32 86 101 114 115 105 111 110 61 49 46 48 46 48 46 48 44 32 67 117 108 116 117 114 101 61 110 101 117 116 114 97 108 44 32 80 117 98 108 105 99 75 101 121 84 111 107 101 110 61 110 117 108 108 5 1 0 0 0 31 67 111 110 115 111 108 101 65 112 112 108 105 99 97 116 105 111 110 49 46 65 99 99 111 117 110 116 73 110 102 111 3 0 0 0 9 117 115 101 114 95 110 97 109 101 7 117 115 101 114 95 105 100 6 97 99 116 105 118 101 1 0 0 8 1 2 0 0 0 6 3 0 0 0 4 69 108 105 111 52 0 0 0 1 11
Which actually contains a lot of 'junk' information like the name of the namespace, class, property's, and such..
I 'stripped' it down a little bit for you: (not everthing, i'm not einstein or such,. can be that i made mistakes,.)
Code:
//??
0 1 0 0 0
//??
255 255 255 255
//??
1 0 0 0 0 0 0 0 12 2 0 0 0
//(string)ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
//74 67 111 110 115 111 108 101 65 112 112 108 105 99 97 116 105 111 110 49 44 32 86 101 114 115 105 111 110 61 49 46 48 46 48 46 48 44 32 67 117 108 116 117 114 101 61 110 101 117 116 114 97 108 44 32 80 117 98 108 105 99 75 101 121 84 111 107 101 110 61 110 117 108 108
//??
5 1 0 0 0
//(string)ConsoleApplication1.AccountInfo
//31 67 111 110 115 111 108 101 65 112 112 108 105 99 97 116 105 111 110 49 46 65 99 99 111 117 110 116 73 110 102 111
//??
3 0 0 0
//(string)user_name
//9 117 115 101 114 95 110 97 109 101
//(string)user_id
//7 117 115 101 114 95 105 100
//(string)active
//6 97 99 116 105 118 101
//??
1 0 0 8 1 2 0 0 0 6 3 0 0 0
//(string)Elio
//4 69 108 105 111
//(int)52
52 0 0 0
//(bool)true
1
//??
11
*counted* yup,. 188
PS:
@
ლ(ಠ_ಠლ) ,
Don't confuse bytes with bits,
A 'normal' size of an int is 4, a 'normal' int also called 'int32', which means it's 4bytes, not 32bytes haha =p that would be a long long number...
PS2:
@
abuckau907 ,
You're kind of right, but, remember that 'usually' a short gets used for a string, that means that it's 2 bytes for the length, it would result into 6+4+1, but also don't forget 'usually' in those case's without (de-)serialize there also would be a 'length' (int/int32) and a 'header' (short/int16) value.. which also will add a total of 6 bytes..
EDIT:
Oh, awesome tutorial btw! (totally forgate to say it D=, but now i did =p)