Wednesday, 14 February 2007

List.Clone ( )

The List class does not expose any form of Clone method—either directly through the List class itself or indirectly through its parent classes and interfaces.

To work around this, the List class does expose the AddRange ( ) method. To “clone” a list, simply create a new List and invoke AddRange ( ), passing in the list to be copied.

The result is a shallow clone of the existing list.

No comments:

Post a Comment

Spam comments will be deleted

Note: only a member of this blog may post a comment.