public class ArrayHolder {

	int[,] array;
	ReceivesArray r;

	public ArrayHolder() {
		array = new int[50, 50];
		// array gets filled
		//...
		r = new ReceivesArray(array);
	}
}

public class ReceivesArray {

	int[,] receivedArray;

	public ReceivesArray(int[,] theArray) {
		receivedArray = theArray;
	}
}

I'm doing something like the example above, but instead of passing the whole array to the class that needs it, I want to pass a pointer to the array produced in ArrayHolder. How would I go about doing this?

While you can use pointers in C# (using unsafe code) what you really want to do is pass a reference. Change your constructor to

public ReceivesArray(ref int[,] the Array) {

and then add ref before any variables used to call the constructor. The compiler will complain if you are doing it wrong :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.