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#?
You could also just break out of the loop if you don't want to use linq.
int count = 0; foreach (var rssItem in rss.Channel.Items) { if (++count == 6) break; ... }