I have the following code
foreach (var rssItem in rss.Channel.Items)
{
// ...
}
But only want 6 items not all items, how can I do it in C#?
Not to be too obvious but...
int max = Math.Min(6, rss.Channel.Items.Count);
for (int i = 0; i < max; i++)
{
var rssItem = rss.Channel.Items[i];
//...
}
I know it's old school, and not filled with all sorts of Extension method goodness, but sometimes the old school still works... especially if you're still using .NET 2.0.