Reputation: 307
How do I remove the first array item from holidayArray
in the following code:
@foreach (var item in holidayArray)
{
<p>@item</p>
}
Upvotes: 0
Views: 389
Reputation: 39274
Simply Skip that first item:
@foreach (var item in holidayArray.Skip(1))
{
<p>@item</p>
}
this will ignore 1 item from the start.
Upvotes: 3
Reputation: 1726
If it is for display in page, then you can ignore the first element by this way
@foreach (var (item, index) in holidayArray.Select((x,i) => (x, i)))
{
if (index > 0) {
@: <p>@item</p>
}
}
Upvotes: 0