Let's say I have a completely empty array
int num = 1;
int[] arr = new int[0];
I just want to add the variable num to the arrat in the next possible position, like the .Add function for lists in C#. How would I do this without having to specify where I put it, only what to put. I do not want to use any Lists, basically just how the .Add function works for lists, but for arrays
I tried just using the .Add function but that didn't work. This was my full code:
public class Program
{
public static int[] MultiplyByLength(int[] arr)
{
int[] finallist = new int[0];
int curnum = 0;
foreach(int item in arr)
{
curnum = item * arr.Length;
finallist.Add(curnum);
}
return(finallist);
}
}
But, clearly, it didn't work. how would I make the finallist.Add(curnum) line to work?