1
我想讀一個XML文件,但得到type of the expression in the select clause is incorrect. Type inference failed in the call to 'Select'
誤差以下查詢的結果:LINQ To XML錯誤:select子句中表達式的類型不正確。類型推斷呼叫失敗「選擇」
List<Data> dogs = (from q in doc.Descendants("dog")
where (string)q.Attribute("name") == dogName
select new Data
{
name = q.Attribute("name").Value,
breed = q.Element("breed").Value,
sex = q.Element("sex").Value
}.ToList<Data>);
數據類:
public class Data
{
public string name { get; set; }
public string breed { get; set; }
public string sex { get; set; }
public List<string> dogs { get; set; }
}
您確定它不是簡單的錯字嗎? –
@lazyberezovsky:我認爲它會相當合理地匹配標題中的錯誤。 –
啊,我的壞 - 沒有看到標題錯誤 –