![]() |
|
[C#] To loop or not to loop? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] To loop or not to loop? (/showthread.php?tid=3667929) |
To loop or not to loop? - jrbuchner - Aug 3, 2013 I have set the values for variables box1 through to box26, how can I display the values of them in the console without writing Console.WriteLine(box1); 26 times? * - 0xDEAD10CC - Aug 4, 2013 Hint: Use an array??? :S (That's what they are for) * - iVision - Aug 4, 2013 var myArray = new [] { 1, 2, 3, 4, 5 ..., 26 }; foreach (var i in myArray) Console.WriteLine(i); Or an for: for (int i = 0; i < myArray.Length; i++>) //.. Or you could use reflection or a list or.. |