joe nesbitt wrote:I wrote a small test to understand. I used a empty String and its byte size is zero. But the byte size of the serialized version is 7 bytes.
Q1) How is that possible?
When you serialize an object, let's say a String, the information which is stored enables anything else to recognize that it is a serialized String. So it's necessary to store information which describes the object as well as storing the contents of the object
Q2) Also I need to some how make the byte size of seriliazed version match the original String size which is zero? How do I accomplish this?
I don't know what "match" means there. If your requirement is that serializing an empty string writes zero bytes, then obviously that's a requirement that can't be implemented.