我想轉換IEnumerable的,下面轉換IEnumerable的<Object>以匿名類型
public class NameVal
{
public string Name { get; set; }
public string Content { get; set; }
}
IEnumerable<NameVal> contents = new List<NameVal>()
{
new NameVal { Name = "title", Content = "My new post" },
new NameVal { Name = "body", Content = "This is my first post!" }
};
定義爲匿名類型「數據」
var data = new
{
title = "My new post",
body = "This is my first post!"
};
任何人都知道如何去嗎?謝謝。
你可以使用字符串,字符串的字典? –