c# - Deep copy helper leads to index out of bounds -


i have dictionary object value dictionary<string, object>. using deep copy creating clone of dictionary. adding clone variable, each key adding key + "string", column in data table contains same number , values of columns key in dictionary. adding updated dictionary[key] list , adding list data table.

this process working fine lead

index outside bounds of array.

and

destination array not long enough copy items in collection. check array index , length.

can me , let me know reason of getting error.

dictionary<string, object> obj=     deepcopyhelper.clone(taskresult.taskstatistics.taskspecificdata.statisticsdata()); var taskspecificrefdata = new dictionary<string, object>(obj); foreach (string key in taskspecificrefdata.keys) {     if (!dtreturn.columns.contains(key + "ref"))     {         dtreturn.columns.add(key + "ref");         datarowobjects.add(taskspecificrefdata[key]);     } } dtreturn.rows.add(datarowobjects.toarray());        public static t clone<t>(t source)         {             if (!typeof(t).isserializable)             {                 throw new argumentexception("the type must serializable.", "source");             }             if (object.referenceequals(source, null))             {                 return default(t);             }             iformatter formatter = new binaryformatter();             stream stream = new memorystream();             using (stream)             {                 formatter.serialize(stream, source);                 stream.seek(0, seekorigin.begin);                 return (t)formatter.deserialize(stream);             }         } 


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -