title: C# Count registry keys existing using a partial value
body: <pre><code>Microsoft.Win32.RegistryKey registryPath = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Testing");
  
  Microsoft.Win32.RegistryKey entryKey = registryPath.OpenSubKey("Entry Point");
  </code></pre>
  
  <p>I have a lot of keys in Testing, in the format: "Entry Point 011", "Entry Point 123" - so Entry Point with random numbers after it.</p>
  
  <p>Would I be able to search the registryPath variable above and get a count of the number of keys containing the "Entry Point" keyword? Assuming that there are also other keys existing without this keyword.</p>
  
  <p>At the moment I have been using a for loop and looping for all possible combinations to get a count of all the keys, checking if the key exists or not, but as there are keys as high as "Entry Point 9000" having a for loop execute 9000 times is very inefficient.</p>
  
  <pre><code> for (int i = 0; i &lt;= highestEntryPointValue; i++)
   {
       Microsoft.Win32.RegistryKey entryKey = steamApps64.OpenSubKey("Entry Point " + Convert.ToString(i));
  
       if (entryKey != null)
       {
           count++;
       }
   }
  </code></pre>