title: C# Noob - Passing a condition as a parameter
body: <p>I already have a solution for this problem, but it seems <em>very</em> confusing and unpractical to me. </p>
  
  <p>What I intend to do is to read a file line-by-line (due to the file size, it's unpractical to load it into memory all at once), and if certain condition is met (e.g.: the line matches a regex pattern, or contains certain keywords, or is equal to certain string)  </p>
  
  <p>Here's what I'd Ideally have:</p>
  
  <pre><code> void TryGetLineIf(string filePath, Condition condition, out string desiredLine)
    {
       StreamReader fileReader = new StreamReader(filePath);
       string currentLine = "";
  
       while (!fileReader.EndOfStream)
       {
          currentLine = fileReader.ReadLine();
  
          if (condition)
          {
             desiredLine = currentLine;
          }
       }
    }
  </code></pre>
  
  <p>However, I don't know what to do with the condition parameter. The only way out I can think of is to replace the condition with an enum, (LineSelectionOptions.IsRegexMatch, LineSelectionOptions.ContainsString ...), add an extra parameter to the void and switch between possible values for it. I'm working with .NET 2.0, if that is relevant.</p>