2013-07-16 19 views

cevap

15

Sen new anahtar kelime sonra sınıf adını eklemeniz gerekir:

IList<FotoLiveLove> fotoLiveLove = xDoc["statuses"].Select(x => new FotoLiveLove() 
{ 
    Tipologia = "twitter", 
    URL = (string)x["URLJSON"] 
}).ToList(); 
+5

+1. Bir yan notda, nesne başlatıcı sözdizimini kullanırsanız, '()' ye ihtiyacınız yoktur. –

2

Sen .Select üzerine türünü belirtmek gerekir. Ben bu durumlarda sorgu formunu kullanmayı tercih (ama bu sadece bir tercih var)

IList<FotoLiveLove> fotoLiveLove = xDoc["statuses"].Select(x => new FotoLiveLove() 
{ 
    Tipologia = "twitter", 
    URL = (string)x["URLJSON"] 
}).ToList(); 
1

: Böyle bir şey deneyin

IList<FotoLiveLove> fotoLiveLove = (from f in x.Doc["statuses"] 
           select new FotoLiveLove(){ 
            Tipologia = "twitter", 
            URL = (string)x["URLJSON"] 
           }).ToList(); 
İlgili konular