title: Shorthand way of adding strings from class into List<string>?
body: <p>I have the following C# code:</p>
  
  <pre><code>List&lt;string&gt; names = new List&lt;string&gt;();
  if (myObject.myClass != null)
  {
       foreach (var foo in myObject.myClass.subClass)
       {
            names.Add(foo.Name);
       }
  }
  </code></pre>
  
  <p>Is there a shorter way of writing this without the need to iterate through each instance of <code>subClass</code> to add <code>myObject.myClass.subClass.Name</code> into the <code>names</code> <code>List&lt;string&gt;</code> object?</p>
  
  <p>Also baring in mind <code>myObject.myClass</code> can be null.</p>