Personally, I never had to use a pointer to C #. If I need such functionality, I write this code in C ++ / CLI and call it from C #. If I need to pass pointers from C # to C ++ / CLI or vice versa, I pass them as IntPtr and pass it to the type that I need in C ++ / CLI.
In my opinion, if you use pointers to C #, in 99% of cases you use the language incorrectly.
Edit: The good thing about C ++ / CLI is that you can mark separate classes for compilation only for the native language. I do a lot of image processing work, which should happen very quickly; it uses a lot of code based on pointers. Usually I have a C ++ / CLI managed object to directly call my own C ++ object, where my processing takes place. I turn on optimization for this native code and viola, I get a good performance boost.
Of course, this only matters if the performance you get by running your own optimized code can offset the overhead of managed unmanaged transitions. In my case, this always happens.
source share