title: Improve Code: Compare 2 list of elements
body: <p>sorry for the newbie question but, I'm new to programming.. </p>
  
  <p>I want to check if there's already no more than one element of <code>TypeA</code> in <code>listOfDifferentTypes</code>. I've following code:</p>
  
  <pre><code>     public void CheckType ( Object param)
       {
              if ( param is TypeA )
              {
                  int i = 0;
                  TypeA paramToCheck = ( TypeA ) param;
  
                  foreach ( var paramB in listOfDifferentTypes )
                  {
                      if ( paramB is TypeA )
                      {
                          var paramInList = ( TypeA ) paramB;
                          if ( paramToCheck.ID == paramInList.ID )
                          {
                              i++;
                          }
                      }
                  }
                  if ( i &gt; 1 )
                  {
                      paramToCheck.m_Error = "ErrorText";
                  }    
              }
      }
  </code></pre>
  
  <p>I consider it's not very clean solution. Can this code be improved / optimized? </p>