What?s the difference between the System.Array.CopyTo() and
System.Array.Clone()?

Answer Posted / sree..

The below code does a deep copy.
Let me know if something is wrong with the code.

string[] array = new string[1] { "aaa" };
string[] copy = new string[1];
array.CopyTo(copy, 0);

copy[0] = "xyz";
Console.WriteLine(array[0]);

I see array[0] value as "aaa".

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a multicast c# delegate?

500


Explain publishers and subscribers in events.

530


What are controls in c#?

463


Can enum be null c#?

514


What do you mean by thread safe in c#?

462






What is arraylist c#?

453


Explain how do you directly call a native function exported from a dll?

495


What are the 3 types of comments in c#?

517


What is the purpose of constructor in c#?

441


What is the difference between virtual method and abstract method?

537


Why do we need generics in c#?

504


Where do we set the min and max pool size for connection pooling?

513


What are classes in c#?

571


Why do we use public static void main in c#?

458


Explain the types of assemblies in .net?

521