title: C# - Populate a list using lambda expressions or LINQ
body: <p>It's been a while since I've used lambda expressions or LINQ and am wondering how I would do the following (I know I can use a foreach loop, this is just out of curiosity) using both methods.</p>
  
  <p>I have an array of string paths (does it make a difference if it's an array or list here?) from which I want to return a new list of just the filenames.</p>
  
  <p>i.e. using a foreach loop it would be:</p>
  
  <pre><code>string[] paths = getPaths();
  List&lt;string&gt; listToReturn = new List&lt;string&gt;();
  foreach (string path in paths)
  {
      listToReturn.add(Path.GetFileName(path));
  }
  
  return listToReturn;
  </code></pre>
  
  <p>How would I do the same thing with both lambda and LINQ?</p>
  
  <p><strong>EDIT:</strong> In my case, I'm using the returned list as an ItemsSource for a ListBox (WPF) so I'm assuming it's going to need to be a list as opposed to an IEnumerable?</p>