1
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)
給我一個錯誤CS1061:「對象」不包含「作者」如何訪問匿名類型?
如何從推薦列表中只得到作者或見證的定義?
+1匿名類型是非常有用的,但在這種情況下,您應該定義一個嚴格的類型。 – 2010-11-13 11:58:03