I study how FileStream is implemented in C# and in the Read(..) method I can see:
n = ReadCore(_buffer, 0, _bufferSize);
...
Buffer.InternalBlockCopy(_buffer, _readPos, array, offset, n);
...
Where Buffer.InternalBlockCopy points to definition (bellow) in buffer.cs. The method BlockCopy is defined as static extern. Where is this method defined? It is part of .NET? It is managed or native?
[System.Runtime.InteropServices.ComVisible(true)]
public static class Buffer
{
// Copies from one primitive array to another primitive array without
// respecting types. This calls memmove internally. The count and
// offset parameters here are in bytes. If you want to use traditional
// array element indices and counts, use Array.Copy.
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void BlockCopy(Array src, int srcOffset,
Array dst, int dstOffset, int count);
..
}