I was struck today, with the inclination to compare the innards of Buffer.BlockCopy and Array.CopyTo. I am curious to see if Array.CopyTo called Buffer.BlockCopy behind the scenes. There is no practical purpose behind this, I just want to further my understanding of the C# language and how it is implemented. Don't jump the gun and accuse me of micro-optimization, but you can accuse me of being curious!
When I ran ILasm on mscorlib.dll I received this for Array.CopyTo
.method public hidebysig newslot virtual final
instance void CopyTo(class System.Array 'array',
int32 index) cil managed
{
// Code size 0 (0x0)
} // end of method Array::CopyTo
and this for Buffer.BlockCopy
.method public hidebysig static void BlockCopy(class System.Array src,
int32 srcOffset,
class System.Array dst,
int32 dstOffset,
int32 count) cil managed internalcall
{
.custom instance void System.Security.SecuritySafeCriticalAttribute::.ctor() = ( 01 00 00 00 )
} // end of method Buffer::BlockCopy
Which, frankly, baffles me. I've never run ILasm on a dll/exe I didn't create. Does this mean that I won't be able to see how these functions are implemented? Searching around only revealed a stackoverflow question, which Marc Gravell said
[Buffer.BlockCopy] is basically a wrapper over a raw mem-copy
While insightful, it doesn't answer my question if Array.CopyTo calls Buffer.BlockCopy. I'm specifically interested in if I'm able to see how these two functions are implemented, and if I had future questions about the internals of C#, if it is possible for me to investigate it. Or am I out of luck?