Simplified the question, this ain’t homework.
In List<Room>, each Room has number of people in this room. Currently I was printing room_id + person_id like so:
foreach(var room in List<Room>)
{
for(var i=0;i<room.numberOfPpl;i++)
{
Console.Write(string.Format("room_id={0} person_id={1}",room.id,i))
}
}
Output: room_id=1 person_id=1, room_id=1 person_id=2, room_id=1 person_id=3 ...
Now my requirement is to loop throughout rooms first:
output: room_id=1 person_id=1, room_id=2 person_id=1, room_id=3 person_id=1, room_id=1 person_id=2 ...
Thanks.
Not that this requires
using System.Linq;.