Sin Jeong-hun,
The easiest way to do this would be to use the ConvertAll method on the
instance itself. You can always convert the list to itself. =)
So, you can do:
// This assumes T is a valid type.
List<List<T>> a = param;
// Make a copy.
List<List<T>> b = a.ConvertAll(delegate(T input) { return input; });
Basically, you are passing the value through to a new list.
Hope this helps.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> List<List<T>> a=param;
> List<List<T>> b=a;
[quoted text clipped - 5 lines]
>
> Thanks.
Sin Jeong-hun - 28 Jul 2006 19:20 GMT
Thank you all!
> Sin Jeong-hun,
>
[quoted text clipped - 26 lines]
> >
> > Thanks.
Jon Shemitz - 28 Jul 2006 19:56 GMT
> // Make a copy.
> List<List<T>> b = a.ConvertAll(delegate(T input) { return input; });
This won't compile - you need to write "ConvertAll<List<T>>". More
importantly, this only clones the 'outer list' - you get a new list of
the same inner List<T> elements. If you want a wholly independent copy
(so that changing one of the lists in the original tree doesn't affect
the copy) you need
List<List<T>> DeepCopy =
List.ConvertAll<List<T>>(delegate(List<T> Branch)
{
return Branch.ConvertAll<T>(delegate(T Leaf){return Leaf;});
});

Signature
.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn In print, in stores.
kjetil.gloppen@gmail.com - 25 Aug 2006 09:51 GMT
> List<List<T>> DeepCopy =
> List.ConvertAll<List<T>>(delegate(List<T> Branch)
> {
> return Branch.ConvertAll<T>(delegate(T Leaf){return Leaf;});
> });
If T is a reference type, this method will still not be "deep" enough.
The leafs will just be refering to the same objects. To fix this I
guess you could make sure T inmplementes ICloneable and let Clone()
return a deap copy of T. Then the code should be:
List<List<T>> DeepCopy =
List.ConvertAll<List<T>>(delegate(List<T> Branch)
{
return Branch.ConvertAll<T>(delegate(T Leaf){return
Leaf.Clone();});
});