-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