-2

I have following foreach loop , I want to skip first result and and get rest of it

    foreach (String W in words)
    {
     ...
    }

How can I do this

Kelum
  • 1,745
  • 5
  • 24
  • 45

2 Answers2

3

Simple use Skip extension method (using LINQ) like this:

   foreach (String W in words.Skip(1))
        {
         ...
        }
blogprogramisty.net
  • 1,714
  • 1
  • 18
  • 22
3

You can use a bit of LINQ to Skip items from the front of an IEnumerable<T>

foreach (String W in words.Skip(1))
{
 ...
}
spender
  • 117,338
  • 33
  • 229
  • 351