title: How to convert a List to IEnumerable?
body: <p>I was solving a problem which needs to write a function that returns only the integers from an object List(I have written the function but it doesn't work). I have thought for a long time how to convert the List to IEnumerable, I was searching how to solve the problem, but I haven't found the right solution yet. Please, can anyone help me with this, maybe easy, problem?</p>
  
  <pre><code>public static IEnumerable&lt;int&gt; GetIntegersFromList(List&lt;object&gt; listOfItems)
  {
      List&lt;object&gt; result = new List&lt;object&gt;();
      for (int i = 0; i &lt; listOfItems.Count - 1; i++)
      {
          if (listOfItems[i] is string)//the input is only integers and strings
          {
              listOfItems.RemoveAt(i);
          }
      }
      return listOfItems;//this doesn't work
  }
  </code></pre>