我有两个班级MoviesListRootObject
和Response
. 我想访问 id、Title 和 description 的MoviesListRootObject
conatins 列表并将其分配给 var。Response
List<Response>
public class MoviesListRootObject
{
public int count { get; set; }
public Pagination pagination { get; set; }
public List<Response> response { get; set; }
}
[Serializable]
public class Response
{
public int id { get; set; }
public string title { get; set; }
public string title_language { get; set; }
public string description { get; set; }
public string description_language { get; set; }
}
现在我可以想到编写 LINQ 来获取包含响应的 MovieDetails 对象,但这无济于事。
var movieResponse = from MoviesListRootObject movieDetail in rootObj
select new MovieDetails
{
Response =movieDetail.response
};