[Mono-list] Socket code.

Michal Moskal malekith@pld-linux.org
Sun, 22 Feb 2004 20:32:58 +0100


On Sun, Feb 22, 2004 at 01:51:18PM -0500, Jonathan Pryor wrote:
> Yes, GetString(byte[]) exists, but it's equivalent to this:
> 
> 	string GetString (byte[] bytes)
> 	{
> 		return GetString (bytes, 0, bytes.Length);
> 	}
> 
> So this is only valid if `bytes' is full.  Otherwise (when you've read
> fewer than `bytes.Length' bytes) the end of your string will contain
> garbage data.  The `GetString (bytes, 0, len)' fixes this, so GetString
> will only convert valid data.

Just a remark: arrays are initialized to zero or null (just checked IL
reference), so it's not exactly garbage.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?