title: How to use a lambda expression to find a string in a list
body: <p>I am trying to use a lambda expression to find a string within a list of items in a list.  I am getting a instance not set to an object error.</p>
  <p>Refer to this simple class as an example</p>
  <pre><code>Public Class Project
  Public ProjectList as New List(Of ProjectType)
  End Class
  
  Public Class ProjectType
  Public Name As String
  End Class
  </code></pre>
  <p>In My Code:</p>
  <pre><code>Dim MyProjectCollection as New List(of Project)
  Dim MyProjectType as New ProjectType
  MyProjectType.Name = &quot;Math&quot; 
  MyProjectCollection.ProjectList.AddItem(MyProjectType) 'adding items to the Project
  </code></pre>
  <p>i am trying to filter out only &quot;Science&quot; Projects like this</p>
  <pre><code>MyProjectCollection.RemoveAll(function(x as Project) x.ProjectType.Name &lt;&gt; &quot;Science&quot;)
  </code></pre>
  <p>it errors, if anyone can point me to what I am doing wrong I would greatly appreciate it.  I know I didn't add a ProjectType.Name = &quot;Science&quot; but just assume its a list already filled.</p>
  <p>I want to remove all Projects where none of the ProjectTypes have a Name of &quot;Science&quot;</p>