c# class
Extreme newbie question here. I want to use a foreach loop to Console.WriteLine all the objects. But how to i turn the "blog1, blog2 and blog3" into "blog" so that i could use the foreach loop?
6 Replies
well, how does a
foreach
loop work?
what does it need?a list of items
how do you create a list of items?
Got it working. I struggled with how list worked.
perfect
only thing I would do differently is make that an array
slightly more efficient
List<T>
will almost certainly allocate more memory than you actually need to store 3 references
although, you can get around that by constructing the list with a specific capacity
but the array version is a little bit cleanerThanks for the help!