- Home /
List out all Array Values.
Is there any way of listing out all array objects in a single textbox string besides doing Textbox.text = Array[0] + Array[1] + Array[2]...;
? I have tried looking this up on the web and along with the unity forums and could only find answers that says how to print each object inside of the array in multiple different lines in the debug console.
Answer by Kishotta · Apr 13, 2019 at 12:29 AM
In order to process each element of an array and aggregate some data about its contents, you should use a loop (in this case, because you can know how large the array is, a for loop).
string aggregateText = "";
for (int index = 0; index < myArray.Length; index++) {
aggregateText += " " + myArray[index]; // Extra addition to put a space between elements
}
Textbox.text = aggregateText;
I have added the code and it worked fine. But how would you reverse the index? I forgot in my question to include that the string actually had to be displayed in reverse. I tried to fix it by myself but I'm not really used to working with arrays and I get an index out of bounds error.
Edit: I fixed my problem by inverting what was given and just taking Array[index-1] and that seemed to solve the problem because the array starts on the 0 digit ins$$anonymous$$d of one.
Your answer
![](https://koobas.hobune.stream/wayback/20220612195356im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
create objects by script and fill them into array 0 Answers
C# convert Bytearray to System.Draw.Image 2 Answers
C# Incrementing a String Array 1 Answer