C
C#2y 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
JakenVeina2y ago
what is "the "Clear" command"?
Juliandyce
JuliandyceOP2y ago
Array.Copy I mean srry
JakenVeina
JakenVeina2y ago
it copies the contents of an array to another array, in the way you tell it to
JakenVeina
JakenVeina2y 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
JakenVeina2y ago
Array.CreateInstance creates an instance of the Array class, for the specied type, with the specified length
Juliandyce
JuliandyceOP2y ago
can u explain copy on the example pls
JakenVeina
JakenVeina2y ago
it copies length elements from index startInd of srcArray into index destArray starting at index 0 per the documentation I linked
Juliandyce
JuliandyceOP2y ago
ty
Accord
Accord2y 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.
Want results from more Discord servers?
Add your server