Is there any difference between Array.Copyand CopyTo? Are they just overloaded?
Array.Copy
CopyTo
Look carefully. Copyis a static method, while it CopyTois an instance method.
Copy
Same functionality, different calling conventions. Copy- a static method, but CopyTo- no.
Array.Copy(arraySrc, arrayDest, arraySrc.length); arraySrc.CopyTo(arrayDest, arraySrc.length);
; .
MSDN:
(Array.CopyTo) System.Collections.ICollection. System.Collections.ICollection , Copy, .
Array.CopyTo
System.Collections.ICollection
, , - , CopyTo, all , Copy
https://msdn.microsoft.com/en-us/library/k4yx47a1.aspxhttps://msdn.microsoft.com/en-us/library/06x742cw.aspx,, :
-, , Array.CopyTo :
This method is equivalent to the standard C / C ++ function memmove, not memcpy.
memmove
memcpy
Who CopyTodoes not have such a description.It is true that copying part of an array is not easy, using CopyTowithout parameters to control the range. However, you can use ArraySegmentor array.Skip(offset).Take(length)to achieve it.And there are no problems in my test.
ArraySegment
array.Skip(offset).Take(length)
Source: https://habr.com/ru/post/1720750/More articles:Exclude weekends and holidays (for example, holidays) from the calculation of the date - sqlIs this NPE-related behavior expected for the Groovy secure navigation operator? - groovyASP.NET DataGrid in repeater - asp.netWhy does the mercury "hg log-style paper" give me a "permission denied" error? - mercurialКакие приложения/решения наиболее подходят для поиска по модели в Django? - djangoКак мыть/проверять строку, чтобы назначить ее имени компонента? - delphiParse a list of attributes / values in PHP - phpGoogle Location APIs and maps: why do identical queries produce different results? - google-mapsTransforming a vertex shader, why do we use 4-dimensional vectors? - mathКак изменить словарь Python по умолчанию, чтобы он всегда возвращал значение по умолчанию - pythonAll Articles