Reputation: 4480
In a function I am taking an array and resizing it. I made the function an array return type and it does what it is supposed to do. The problem I am having is figuring out how to use the returned array in my program. hiLow is a function that takes the array and changes the value, the for loop only still shows the old array. How do I get creature(the name of my array) to only display the new values?
hiLow(creature);
for (int i = 0; i < 2; i++)
{
Console.WriteLine(creature[i].creatureInfo());
}
Upvotes: 0
Views: 187
Reputation: 3111
Without knowing exactly what is going on without seeing your code, one thing you will want to do is pass the array by reference into your hiLow
method. This will modify the array that is being passed in and you should be able to see the new size of your array in the loop.
hiLow(ref creature);
for (int i = 0; i < 2; i++)
{
Console.WriteLine(creature[i].creatureInfo());
}
Upvotes: 1