如何将2dArray复制到另一个 [英] how to copy 2dArray to another one

查看:82
本文介绍了如何将2dArray复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int [,] 2darray;

int [,] 2dcopy;

int[,] 2darray;
int [,]2dcopy;

推荐答案

以下是LinqPad [ ^ ]用于演示的脚本,粗体部分是您正在寻找的基本想法:

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

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

A.Dump();
B.Dump();


您可以随时试用文档:



Array.Copy方法(数组,数组,Int32)



You could always try the documentation:

Array.Copy Method (Array, Array, Int32)

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);



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;
    }


这篇关于如何将2dArray复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆