Skip to content
Sign upLog in

How do I print this list using my class method?

Profile icon
AureyLia

My only trouble is line 46. How do I print my list items using my method (ToString()) I created under the House class? Right now it's only printing the name of the list...

I want my output to be "House at 123 Main Street has 2 bedrooms and 4 bathrooms." and so on for each list item.

You are viewing a single comment. View All
Profile icon
SixBeeps

Right now you're trying to print the list itself, not the items of the list. If you want to print out each House element one-by-one, you need to iterate over the whole list and print them like that. Something like

foreach (House home in houseList) Console.WriteLine(home);
Profile icon
AureyLia

Thank you so much!