I’ve been trying to create a simple calendar interface using a table, but I keep getting pesky “out of memory” exceptions….am I missing something? Is there a better way to do this?
Just for a note, the TimePeriod1 and TimePeriod2 are just the days of the month split up, ie, day 1-15 and day 16-29.
<tbody>
<% int days = Model.TimePeriod1.Count + Model.TimePeriod2.Count;
int day = 1;
while (day < days) { %>
<tr>
<% while ((day % 7) != 0){ %>
<td><%: day++ %></td>
<% } %>
</tr>
<% } %>
</tbody>
When
dayreaches the number 7, it will break the inner while and go back to the second one. Ifdaysis greater than 7, it will continue to loop but will neved enter the inner while again, that’s why you are getting a OOM exception.One possible solution is to add
day++before the end of the first while: