When using a pointer to an array, I've always accessed the elements by using an indexer, such as, myPtr[i] = stuff
; however, I was recently looking over BitConverter
's implementation and discovered that elements were accessed by doing, *(myPtr + i) = stuff
.
Which I thought was quite odd, since both methods (from what I know) do the exact same thing, that is, they return the address of myPtr + i
, except (in my opinion) the indexer method looks much more readable.
So why did Microsoft choose to increment pointers the way they did, what's the difference between the two methods (are there performance benefits)?