小编Tix*_*xiv的帖子

如何访问匿名类型?

List<Object> testimonials = new List<Object>();
testimonials.Add(new {
    Author = "Author 1",
    Testimonial = "Testimonial 1"
});
testimonials.Add(new {
    Author = "Author 2",
    Testimonial = "Testimonial 2"
});
testimonials.Add(new {
    Author = "Author 3",
    Testimonial = "Testimonial 3"
});

@ObjectInfo.Print(testimonials[DateTime.Now.DayOfYear % testimonials.Count].Author)
Run Code Online (Sandbox Code Playgroud)

给我一个错误CS1061:'object'不包含'Author'的定义

如何从推荐书列表中仅获得作者或推荐书?

c# anonymous-types webmatrix

1
推荐指数
1
解决办法
343
查看次数

标签 统计

anonymous-types ×1

c# ×1

webmatrix ×1