Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
int[,] 2darray;
int [,]2dcopy;
Posted
Comments
Maciej Los 5-May-13 16:51pm    
What have you done so far?

Following is a LinqPad[^] script for demonstration, the bold part is the basic idea you are looking for:
C#
int[,] A = {{1,2},{3,4},{5,6}};
int[,] B ;

B = (int[,])A.Clone();
A[0,0] = 99;

A.Dump();
B.Dump();
 
Share this answer
 
You could always try the documentation:

Array.Copy Method (Array, Array, Int32)

C#
int[,] a1 = new int[4, 6];
a1[2, 3] = 4;
a1[3, 5] = 25;
int[,] a2 = new int[a1.GetUpperBound(0) + 1, a1.GetUpperBound(1) + 1];
Array.Copy(a1, a2, a1.Length);
 
Share this answer
 
C#

C#
public static int[,] copying2dArray(int[,] array, int rowLength, int clumnLength)
    {

        int[,]Copy = new int[rawLength, columnLenggth];
        for (int i = 0; i < rooms; i++)
        {
            for (int j = 0; j < timeSlots; j++)
            {
                Copy[i, j] = aray[i, j];
            }
        }
        return populationCopy;
    }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900