-1
我在C#中遇到數組或JSON的問題。問題是,我想在現有對象內插入數組。向數組插入/添加數組
class Bands
{
public string BandName { get; set; }
public string Songtitle { get; set; }
}
public JsonResult Band()
{
var items = new Bands()
{
BandName = "amber",
Songtitle = //how to add array here;
};
return Json(items, JsonRequestBehavior.AllowGet);
}
輸出:
[
{ "bandname": "maroon", "songtitle": {} },
{ "bandname": "amber pacific", "songtitle": {} }
]
如何插入歌名?
你能更具體?這有點模糊......請參閱https://stackoverflow.com/help/mcve – benichka
你需要一個字符串數組嗎? – 2017-10-06 09:13:59
將'songtitle'更改爲集合。 '公開名單歌詞{get;組; }' –
Fabio