c# - Why does my list display with each object being "System.Collections.Generic.List`1[System.DateTime]" -
i want list starts 5 days before today , ends 10 days after today. in list want generate each day bullet point.
i seem getting correct number of bullet points each 1 has value of system.collections.generic.list`1[system.datetime]
my code below:
@{ var dates = new list<datetime>(); var start = datetime.now; var end = start.adddays(10); (var dt = start; dt <= end; dt = dt.adddays(1)) { <li>@dates</li> dates.add(dt); } }
displays:
system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime] system.collections.generic.list`1[system.datetime]
i sure whatever missing obvious...and feel stupid, appreciated.
that's telling do.
for (var dt = start; dt <= end; dt = dt.adddays(1)) { <li>@dates</li> <-- each iteration, print dates.tostring dates.add(dt); }
the funcition list<datetime>.tostring()
returns typename, in long form system.collections.generic.list1[system.datetime]
.
try code:
for (var dt = start; dt <= end; dt = dt.adddays(1)) { <li>@dt</li> dates.add(dt); }
Comments
Post a Comment