C# does support pointers in unsafe code. Also, if you are making calls
to unmanaged code, pointers are represented in with the IntPtr structure (in
safe code), and can be manipulated through various API calls, as well as
calls to the methods on the Marshal class.
You need to use the unsafe keyword, to make a block for the pointer.
unsafe {
fixed (int* pInt = (int*)intArray) {
// work with the pInt here
}
}
This will not be garbage collected.
You may want to think whether you really need pointers, as C# tries
to be safer than C/C++, and not allowing pointers is one of the way to
try to help.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.