An array is a fixed
collection of same-type data that are stored contiguously.
Arrays are declared much like variables, with a set of [] brackets after the data type, like this:
You need to instantiate the array to use it, which is done like this:
string[] names = new string[2];
Arrays are declared much like variables, with a set of [] brackets after the data type, like this:
You need to instantiate the array to use it, which is done like this:
string[] names = new string[2];
Differrence between
Array.CopyTo() and Array.Clone()
Both CopyTo() and Clone() make shallow copy (data is copied) and
used for Single Dimension arrays.
Clone() method makes a clone of the original array.
It returns an exact length array.
CopyTo() copies the elements from the original array to the destination array starting at the specified destination array index. Note that, this adds elements to an already existing array.
No comments:
Post a Comment