-1

Possible Duplicate:
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

When to use copyto() and Clone().. is there any scenarios to use? i know Clone() always return object.. so we need cast..

Community
  • 1
  • 1
selvaraj
  • 889
  • 2
  • 16
  • 29

3 Answers3

1

...to boldly (and italically in this case) ask what other developers have asked before... ;-)

Difference between the System.Array.CopyTo() and System.Array.Clone()

Community
  • 1
  • 1
Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
  • if you're confident that it's a dupe, use the "Close" link and cite that question as the duplicate. *Don't* put it as an answer as it's not. – Rob Sep 02 '10 at 09:24
  • @Rob: I know, but I couldn't help making this pun on words given the duplicity AND the font type of the OP. – Adrian Grigore Sep 02 '10 at 09:27
0

Depends what your trying to do, Copyto() will add to an already existing array, whereas Clone() will make a duplicate.

Matthew
  • 55
  • 1
  • 6
0

Assuming you have asked question with respect to arrays,

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array.
when you want to copy the elements from one array to another existing array you can use CopyTo() else use Clone().

stacknewbee
  • 169
  • 1
  • 3
  • 15