Although Maciej is correct, you probably shouldn't be using pointers directly in C# - that's one of the reasons why it is difficult to do: to remind you that this is not a good idea unless you really, really, need to (and in the 14 years I've been using C#, I haven't needed a single pointer yet).
Instead, you need to stop assuming that C (or C++) and C# are the same language, and realize that they are very different languages which share some similar syntax. Trying to write C code in C# will end up with bad code that is hard to use, hard to maintain, and hard to read.
The C# equivalent of that code doesn't need pointers because C# is
reference
based - and you can consider references as "pointers on steroids"!
private static void f(int p, ref int q)
{
q = 2;
}
private static int i = 0, j = 1;
public static int Main()
{
f(i, ref j);
Console.WriteLine($"{i} {j}");
return 0;
}
But if you use more complex objects, you don't need to pass by reference at all.