by
84k 18
0
6
113k
0
Top 1% !
Pearl of Wisdom
Tagged
Specified
Refined
OpenSource
Popularity: 19275th place

Published on:

Architecturex86_64
InputName0list
InputType0T
LanguageC#
LanguageCSharp
MethodNameDeepClone
OutputTypeT
Windows VersionWindows7

DeepClone: Copies a collection by calling the ICloneable.Clone method for each element inside it.

Copies a collection by calling the ICloneable.Clone method for each element inside it.

 
<typeparam name="T"></typeparam>
y><param name="list">The collection to be cloned.</param>
 
<returns>A copy of the collection where each element has also been copied.</returns>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1382916/DeepClone--Copies-a-collection-by-callin?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/// <summary> /// Copies a collection by calling the ICloneable.Clone method for each element inside it. /// </summary> /// /// <typeparam name="T"></typeparam> /// <param name="list">The collection to be cloned.</param> /// /// <returns>A copy of the collection where each element has also been copied.</returns> /// public static T DeepClone<T>(this T list) where T : IList<ICloneable>, ICloneable { T clone = (T)list.Clone(); for (int i = 0; i < clone.Count; i++) clone[i] = (ICloneable)list[i].Clone(); return clone; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus