title: C# Dictionary ContainsKey Vs Keys.Any()
body: <p>Here is my situation:</p>
  
  <p>I am using dictionary object to store some keys, and then based on key exists in the object, code is performing some action. </p>
  
  <p>Till now I was using - LINQ - <code>Any()</code> <code>dictionaryObject.Any(x =&gt; x.Key.Equals("SomeParameter"))</code>. This was working will and satisfying all scenarios till my dictionary object suddenly got 200,000 keys.</p>
  
  <p>It started impacting on performance, and so does rest of process.</p>
  
  <p>Then I realize, there is a dictionary method <code>ContainsKey("SomeParameter")</code>, and after using this, performance really improved.</p>
  
  <p>Now I am more interested to see what <code>ContainsKey</code> does different than LINQ <code>Any</code> as I underlined code uses <code>for</code> &amp; <code>foreach</code> respectively, which means it loops thru the list.</p>