title: How to parse out all unique variables with a certain naming convention?
body: <p>I have a code file and I need to find all unique objects of type <code>TADODataSet</code>, but they aren't defined in this 30,000 line file I have.</p>
  
  <p>I wrote a console application that splits each line into individual words and adds that word to a list if it contains <code>ADODataSet</code> (the naming convention prefix for the objects I'm interested in) but this didn't work quite right because of how I'm splitting my lines of code.</p>
  
  <p>This is all of my code:</p>
  
  <pre><code>    static void Main(string[] args)
      {
          string file = @"C:\somePath\Form1.cs";
          string output = @"C:\someOtherPath\New Text Document.txt";
          List&lt;string&gt; datasets = new List&lt;string&gt;();
          string[] lines = File.ReadAllLines(file);
  
          foreach (string line in lines)
          {
              string[] words = line.Split(' ');
  
              foreach (string word in words)
              {
                  if (word.ToLower().Contains("adodataset"))
                      datasets.Add(word);
              }
          }
  
          if (datasets.Count &gt; 0)
          {
              using (StreamWriter sw = new StreamWriter(output))
              {   
                  foreach (string dataset in datasets.Distinct())
                  {
                      sw.WriteLine(dataset);
                  }
              }
  
              Console.WriteLine(String.Format("Wrote {0} data sets to {1}", datasets.Distinct().Count(), output));
              Console.ReadKey();
          }
      }
  </code></pre>
  
  <p>But this didn't work as I hoped, and added "words" such as these:</p>
  
  <pre><code>SQLText(ADODataSetEnrollment-&gt;FieldByName("Age1")-&gt;AsString)
  SQLText(ADODataSetEnrollment-&gt;FieldByName("Age2")-&gt;AsString)
  SQLText(ADODataSetEnrollment-&gt;FieldByName("Age3")-&gt;AsString)
  </code></pre>
  
  <p>I'm only interested in <code>ADODataSetEnrollment</code>, so I should only have 1 entry for that variable in my output file but because that line of code doesn't contain a space it's treated as a single "word".</p>
  
  <p>How can I split my <code>lines</code> array instead, so that way I can find unique variables?</p>