What is the counterpart of this C pointer programme in C#?

Mar 18 2021 4:04 PM
I'd like to know how the following program on pointer written in C can be written in C#, especially how to use the keywords in the C program like &i and *p in C#. Please clarify.
  1. void f(int *p, int *q)  
  2. {  
  3.     p = q;  
  4.     *p = 2;  
  5. }  
  6.   
  7. int i = 0, j = 1;  
  8.   
  9. int main()  
  10. {  
  11.     f(&i, &j);  
  12.     printf("%d %d \n", i, j);  
  13.     return 0;  
  14. }  

Answers (2)