// (c) 2003 Ximian, Inc. (http://www.ximian.com)
//
+using System.Runtime.InteropServices;
+
namespace System.IO
{
[Serializable]
public MemoryStream (byte [] buffer)
{
+ if (buffer == null)
+ throw new ArgumentNullException ("buffer");
+
InternalConstructor (buffer, 0, buffer.Length, true, false);
}
public MemoryStream (byte [] buffer, bool writeable)
{
+ if (buffer == null)
+ throw new ArgumentNullException ("buffer");
+
InternalConstructor (buffer, 0, buffer.Length, writeable, false);
}
return internalBuffer;
}
- public override int Read (byte [] buffer, int offset, int count)
+ public override int Read ([In,Out] byte [] buffer, int offset, int count)
{
CheckIfClosedThrowDisposed ();
if (!canWrite)
throw new NotSupportedException ("Cannot write to this stream.");
- if (position + 1 >= capacity)
+ if (position >= capacity)
Capacity = CalculateNewCapacity (position + 1);
if (position >= length)
stream.Write (internalBuffer, initialIndex, length - initialIndex);
}
}
-}
-
+}