Trying to understand Pointer Arithmetic when dealing with arrays. It seems to me they’re used for fast access of arrays, but maybe I’m totally wrong. I mean if we have this:
*(myArray + 1), we’re going to the next location in the array I think.
I’m converting some C++ to C# and the C++ has pointer arithmetic going on. I need the C# to be totally managed so trying to figure out how to translate the pointer stuff to C#.
THanks for any ideas.
David
If you’re not completely comfortable with pointers, your life will be a bit easier in C#. First off, the code you posted:
Your understanding is basically correct, you are dereferencing the 1st element in
myArray. Or in other words, accessingmyArray[1].Moving to C#, you likely use a generic
List<T>whereTis the type of yourmyArray. Similar syntax is available to you –myArray[i], plus many more functions on theList.