❔ Erklärung an Beispiel
First of all: I am new to programming.
I would like to get an explanation of the "Copy" command to the following example (as simple as possible):
int[] randNums = { 1, 4, 9, 2 };
Array.Sort(randNums);
Array.Reverse(randNums);
int[] srcArray = { 1, 2, 3 };
int[] destArray = new int[2];
int startInd = 0;
int length = 2;
Array.Copy(srcArray, startInd, destArray, 0, length);
PrintArray(destArray, "Copy");
And then of "Array.CreateInstance " too:
Array anotherArray = Array.CreateInstance(typeof(int),length);
ty
10 Replies
what is "the "Clear" command"?
Array.Copy I mean srry
it copies the contents of an array to another array, in the way you tell it to
Array.Copy Method (System)
Copies a range of elements in one Array to another Array and performs type casting and boxing as required.
Array.CreateInstance
creates an instance of the Array
class, for the specied type, with the specified lengthArray.CreateInstance Method (System)
Initializes a new instance of the Array class.
can u explain copy on the example pls
it copies
length
elements from index startInd
of srcArray
into index destArray
starting at index 0
per the documentation I linkedty
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.