Note that there are some explanatory texts on larger screens.

plurals
  1. POPossible to Inspect Innards of Core C# Functionality
    text
    copied!<p>I was struck today, with the inclination to compare the innards of <code>Buffer.BlockCopy</code> and <code>Array.CopyTo.</code> I am curious to see if <code>Array.CopyTo</code> called <code>Buffer.BlockCopy</code> 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!</p> <p>When I ran ILdasm on mscorlib.dll I received this for <code>Array.CopyTo</code></p> <pre><code>.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 </code></pre> <p>and this for <code>Buffer.BlockCopy</code></p> <pre><code>.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 </code></pre> <p>Which, frankly, baffles me. I've never run ILdasm 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 href="https://stackoverflow.com/questions/2353947/buffer-blockcopy-vs-unsafe-byte-pointer-copy">a stackoverflow question</a>, which Marc Gravell said</p> <blockquote> <p>[<code>Buffer.BlockCopy</code>] is basically a wrapper over a raw mem-copy</p> </blockquote> <p>While insightful, it doesn't answer my question if <code>Array.CopyTo</code> calls <code>Buffer.BlockCopy</code>. 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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload