Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
リストがあるとしましょう:
var list = new List<int>{1,2,3};
オブジェクトが次のようになるように、これを匿名オブジェクトに追加するにはどうすればよいですか。
{ list : [1,2,3] }
var obj = new { list = list };
objlistは、タイプと呼ばれるプロパティを持つ無名オブジェクトになりましたList<int>。
obj
list
List<int>
匿名オブジェクトを作成することにより:
var anon = new { list }
私はあなたがそれを次のように見せたいと言うことで仮定します:
JSONシリアライゼーションの出力について話しているのですが、シリアライズすると次のようになります。