C
C#13mo ago
Juliandyce

❔ 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
JakenVeina
JakenVeina13mo ago
what is "the "Clear" command"?
Juliandyce
Juliandyce13mo ago
Array.Copy I mean srry
JakenVeina
JakenVeina13mo ago
it copies the contents of an array to another array, in the way you tell it to
JakenVeina
JakenVeina13mo ago
Array.Copy Method (System)
Copies a range of elements in one Array to another Array and performs type casting and boxing as required.
JakenVeina
JakenVeina13mo ago
Array.CreateInstance creates an instance of the Array class, for the specied type, with the specified length
Juliandyce
Juliandyce13mo ago
can u explain copy on the example pls
JakenVeina
JakenVeina13mo ago
it copies length elements from index startInd of srcArray into index destArray starting at index 0 per the documentation I linked
Juliandyce
Juliandyce13mo ago
ty
Accord
Accord13mo ago
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.