title: Null Exception with Array.FindIndex searching in a string array in C#
body: <p>Someone has chosen to mark this as duplicate, and though I can appreciate trying to clean up a question asking community, the I have examined the "duplicated" material in detail prior to posting my question. As indicated in my question below, I show the outputs of the issue in question, which has no nulls. </p>
  
  <p>I have a method I create based on a user selecting a spinner value that looks like this:</p>
  
  <pre><code>    public void terrain_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
      {
          Spinner spinner = (Spinner)sender;
          var ttype = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
          Console.WriteLine(ttype);
          foreach (var item in Terrainstr) { Console.WriteLine(item); }
          var index = Array.FindIndex(Terrainstr, x =&gt; x.Contains(ttype));
  </code></pre>
  
  <p>As you can see, the string ttype is simply the selection the user makes with the spinner.</p>
  
  <p>I have a string array Terrainstr that's initialized before OnCreate like this:</p>
  
  <pre><code>string[] Terrainstr = new string[10];
  </code></pre>
  
  <p>I populate it later with string fragments based on a number of user selections.</p>
  
  <p>You'll notice I have Console.WriteLine commands in the method. My  (annotated) output when that method is used is:</p>
  
  <pre><code>Fast (ttype)
  Stock (Terrainstr[0])
  Slow 
  Slow Sand 
  Slow Sand Rocks Whoops 
  Slow Sand Mud Rocks Whoops 
  Slow Mud Rocks Whoops 
  Slow Mud Rocks (Terrainstr[6])
  </code></pre>
  
  <p>I want to find which indeces of Terrainstr contain ttype. In this case, it wouldn't fit it at all. I get a null exception using the command shown here:</p>
  
  <pre><code>var index = Array.FindIndex(Terrainstr, x =&gt; x.Contains(ttype));
  </code></pre>
  
  <p>Please advise!</p>