need help in using Reference type for pointers
-
Hi, I'm using reference types in c# instead of pointers...so in below code i'm sending the ptr which is a pointer but using ref key word now can any one tell me how to increament the pointer *(ptr+i) in c#? int Largest(ref int ptr,int Icount) { int largest =0; largest = *(ptr+0); for(int i=0; i < Icount; i++) { if( *(ptr+i) >= largest) { largest = *(ptr + i); } } return largest; }
-
Hi, I'm using reference types in c# instead of pointers...so in below code i'm sending the ptr which is a pointer but using ref key word now can any one tell me how to increament the pointer *(ptr+i) in c#? int Largest(ref int ptr,int Icount) { int largest =0; largest = *(ptr+0); for(int i=0; i < Icount; i++) { if( *(ptr+i) >= largest) { largest = *(ptr + i); } } return largest; }
If you pass an int by ref, it's not really a pointer. You can increment the value, but you can't use it as a memory address, at least not easily. Christian Graus - Microsoft MVP - C++