Array Deep Clone - CSharp System

CSharp examples for System:Array Convert

Description

Array Deep Clone

Demo Code

/*/*from  w w  w  .  jav  a  2 s .c o m*/
* Copyright (c) 2005 Poderosa Project, All Rights Reserved.
* $Id: RCollectionUtil.cs,v 1.2 2005/04/20 08:45:45 okajima Exp $
*/
using System.Collections;
using System;

public class Main{
    public static Array DeepClone(Array src, Type type) {
         Array n = Array.CreateInstance(type, src.Length);
         for(int i=0; i<n.Length; i++) {
            object t = src.GetValue(i);
            n.SetValue(t==null? null : ((ICloneable)t).Clone(), i);
         }
         return n;
      }
}

Related Tutorials