title: Method return type list<string> or generic method?
body: <p>I would like that the method has a specfic return type, but somehow I cannot make it work.</p>
  
  <p>I have an XML structure:</p>
  
  <pre><code>&lt;Notifications&gt;
     &lt;Alerts&gt;
        &lt;Max&gt;3&lt;Max/&gt;
        &lt;Med&gt;2&lt;Med/&gt;
        &lt;Min&gt;1&lt;Min/&gt;
     &lt;/Alerts&gt;
  &lt;/Notifications&gt;
  </code></pre>
  
  <p>I would like to get out the values of <code>Max</code>, <code>Med</code>, <code>Min</code>. But the main point is I DO NOT want any foreach loops at all, I only want that the method has a List&lt;string> return type, or even better to make a generic return type.</p>
  
  <p>The point is, I don't have any custom class (and I don't want to have it) that I would fill its properties.</p>
  
  <p>This is what I have some far, but I got an error on the "List()" annonymus method:</p>
  
  <pre><code>Here it returns:
  List&lt;string&gt; items = GetAlerts();
  
  //method to read:
  public List&lt;string&gt; GetAlerts()
  {
      return xmlDoc1.Descendants("Notifications").Elements("Alerts").Select(s =&gt; new
      {
          MAX = s.Element("Max").Value,
          MED = s.Element("Med").Value,
          MIN = s.Element("Min").Value
       }).ToList(); //error on this line
  }
  </code></pre>
  
  <h2>----------</h2>
  
  <hr>
  
  <p>And how would it look that this method about would be a generic return type? This is NOT OK:</p>
  
  <pre><code>Here it returns: 
  List&lt;object&gt; items = setBLL2.GetAlert&lt;List&lt;object&gt;&gt;();
  
  public T GetAlert&lt;T&gt;() where T:class
  {
      return (T)xmlDoc1.Descendants("Notifications").Elements("Alerts").Select(s =&gt; new
      //ERROR up here before (T
      {
           MAX = s.Element("Max").Value,
           MED = s.Element("Med").Value,
           MIN = s.Element("Min").Value
       }).ToList();
  }
  </code></pre>
  
  <p>The error message is: </p>
  
  <blockquote>
    <p>Cannot convert type 'System.Collections.Generic.List' to 'T'</p>
  </blockquote>