Need help in parameter passing by Reference
-
Hi, Can i know how to pass the address of the variable in c#? Following is the code in c which has to be converted into c#.. public int Largest(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; } plz let me know how to sent the reference and increament the pointer.
-
Hi, Can i know how to pass the address of the variable in c#? Following is the code in c which has to be converted into c#.. public int Largest(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; } plz let me know how to sent the reference and increament the pointer.
you can use ref key word in c# to send the reference of variable public 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; } rahul -- modified at 5:08 Monday 15th May, 2006
-
you can use ref key word in c# to send the reference of variable public 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; } rahul -- modified at 5:08 Monday 15th May, 2006
Thanks Rahul... But i'm getting error "Identifier Expected" so any idea....
-
Thanks Rahul... But i'm getting error "Identifier Expected" so any idea....