title: Complexity of foreach() in C# . NET
body: <p>Friends, I am using C# . NET where I need to read 8 millions line from a file and compute on it. When I do same operation in C language, it takes time but not to much while in C# it goes to very very high time complexity in the loop I mentioned below. Is it like foreach() is having high complexity? What could be the reason of difference between both?</p>
  
  <pre><code>foreach(string currLine in file.lines)
  {
      Tuple tpl = new Tuple(currLine,file.keyLength);
      Console.WriteLine(file.lines.IndexOf(currLine));
  
      if(tpl.isWeakKey(B)==true)
      {
          int nextKey=tpl.findNextKey(B);
  
          if (differentKeys.ContainsKey(nextKey))
          {
              differentKeys[nextKey] = differentKeys[nextKey]+1;
          }
          else
          {
              differentKeys[nextKey] = 1;
          }
      }
  }
  </code></pre>