Can I populate a list of my own class directly in LINQ?
c#, linq
Solution
You need to add your class name after the `new` keyword:
IList<FotoLiveLove> fotoLiveLove = xDoc["statuses"].Select(x => new FotoLiveLove()
{
Tipologia = "twitter",
URL = (string)x["URLJSON"]
}).ToList();
Problem
This is the example: ``` public class FotoLiveLove { public string Tipologia { get; set; } public string URL { get; set; } } IList<FotoLiveLove> fotoLiveLove = xDoc["statuses"].Select(x => new { Tipologia = "twitter", URL = (string)x["URLJSON"] }).ToList(); ``` but it says acnnot convert Anonymous type #1 to FotoLiveLove.