title: Generic method to map objects of different types
body: <p>I would like to write Generic Method that would map List to new list, similar to JS's map method. I would then use this method like this:</p>
  
  <pre><code>var words= new List&lt;string&gt;() { "Kočnica", "druga beseda", "tretja", "izbirni", "vodno bitje" };
  List&lt;object&gt; wordsMapped = words.Map(el =&gt; new { cela = el, končnica = el.Končnica(5) });
  </code></pre>
  
  <p>I know there's Select method which does the same thing but I need to write my own method. Right now I have this:</p>
  
  <pre><code>public static IEnumerable&lt;object&gt; SelectMy&lt;T&gt;(this IEnumerable&lt;T&gt; seznam, Predicate&lt;T&gt; predicate)
  {
      List&lt;object&gt; ret = new List&lt;object&gt;();
  
      foreach (var el in seznam)
          ret.Add(predicate(el));
  
      return ret;
  }
  </code></pre>
  
  <p>I also know I could use <code>yield return</code> but again I mustn't. I think the problem is with undeclared types and compiler can't figure out how it should map objects but I don't know how to fix that. All examples and tutorials I found map object of same types.</p>