Click here to Skip to main content
15,905,322 members
Home / Discussions / C#
   

C#

 
GeneralRe: Space Elevator Problem Pin
Christian Graus7-Feb-07 14:16
protectorChristian Graus7-Feb-07 14:16 
GeneralRe: Space Elevator Problem Pin
Not Active7-Feb-07 14:23
mentorNot Active7-Feb-07 14:23 
AnswerRe: Space Elevator Problem Pin
Christian Graus7-Feb-07 14:15
protectorChristian Graus7-Feb-07 14:15 
QuestionLeave event not firing Pin
kumar.bs7-Feb-07 13:32
kumar.bs7-Feb-07 13:32 
AnswerRe: Leave event not firing Pin
Dave Kreskowiak7-Feb-07 14:05
mveDave Kreskowiak7-Feb-07 14:05 
GeneralRe: Leave event not firing Pin
kumar.bs7-Feb-07 14:27
kumar.bs7-Feb-07 14:27 
QuestionListbox Help Pin
Saamir7-Feb-07 12:07
Saamir7-Feb-07 12:07 
QuestionDeep copy and shallow copy with List<> [modified] Pin
jeffb427-Feb-07 10:51
jeffb427-Feb-07 10:51 
Hello, I'm using C# 2.0 generics in an application I'm writing and I have a question about copying one list to another.

The List<> generic doesn't seem to have a deep copy method. It has CopyTo() but this copies to an array, not to a List<>.

Suppose I have a large list of objects:

main()
{
List<MyClass> original = new List<MyClass>();
// add 10000 MyClass objects to original...
// ...<snip>...

List<MyClass> backup = new List<MyClass>();
ShallowCopy<MyClass>(original, backup);
}

static void ShallowCopy<T>(List<T> source, List<T> dest)
{
dest.Clear();
foreach(T t in source)
{
dest.Add(t);
}
}


OK, this gives me a shallow copy, but what if I want a deep copy? It doesn't look like there's a deep copy built into generics... or what am I missing?


Thanks,

Jeff



-- modified at 17:27 Wednesday 7th February, 2007
QuestionCheck for an existing item in a treeview Pin
sharpiesharpie7-Feb-07 9:43
sharpiesharpie7-Feb-07 9:43 
AnswerRe: Check for an existing item in a treeview Pin
led mike7-Feb-07 9:48
led mike7-Feb-07 9:48 
GeneralRe: Check for an existing item in a treeview Pin
sharpiesharpie7-Feb-07 9:51
sharpiesharpie7-Feb-07 9:51 
AnswerRe: Check for an existing item in a treeview Pin
PIEBALDconsult7-Feb-07 10:00
mvePIEBALDconsult7-Feb-07 10:00 
GeneralRe: Check for an existing item in a treeview Pin
sharpiesharpie8-Feb-07 1:25
sharpiesharpie8-Feb-07 1:25 
AnswerRe: Check for an existing item in a treeview Pin
Ravi Bhavnani7-Feb-07 11:13
professionalRavi Bhavnani7-Feb-07 11:13 
AnswerRe: Check for an existing item in a treeview Pin
Abisodun7-Feb-07 13:53
Abisodun7-Feb-07 13:53 
Questionhow to szie the window? Pin
Khoramdin7-Feb-07 9:33
Khoramdin7-Feb-07 9:33 
AnswerRe: how to szie the window? Pin
sharpiesharpie7-Feb-07 9:46
sharpiesharpie7-Feb-07 9:46 
AnswerRe: how to szie the window? Pin
Ravi Bhavnani7-Feb-07 11:20
professionalRavi Bhavnani7-Feb-07 11:20 
QuestionDecoding Attachment from rfc822? Pin
Eddymvp7-Feb-07 8:57
Eddymvp7-Feb-07 8:57 
AnswerRe: Decoding Attachment from rfc822? Pin
Guffa7-Feb-07 9:03
Guffa7-Feb-07 9:03 
GeneralRe: Decoding Attachment from rfc822? Pin
Eddymvp7-Feb-07 10:04
Eddymvp7-Feb-07 10:04 
AnswerRe: Decoding Attachment from rfc822? Pin
Guffa8-Feb-07 3:13
Guffa8-Feb-07 3:13 
QuestionHow to Browse , select a file and store it onto the txtbox Pin
Eyungwah7-Feb-07 8:22
Eyungwah7-Feb-07 8:22 
AnswerRe: How to Browse , select a file and store it onto the txtbox Pin
Ravi Bhavnani7-Feb-07 8:30
professionalRavi Bhavnani7-Feb-07 8:30 
AnswerRe: How to Browse , select a file and store it onto the txtbox Pin
Stefan Troschuetz7-Feb-07 8:30
Stefan Troschuetz7-Feb-07 8:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.