List<Customer> c= new List<Customer>()
{
new Customer{Id = 1, Name = "Bruce"},
new Customer{Id = 2, Name = "John"}
};
我只是知道
c.ForEach(o => str += o.Id.ToString() + ",");
有简单的方法吗?
我只想取出Id并创建Ids数组 int[] Ids = new {Id = 1, Id = 2}
var visitorsData = @Html.Raw(Json.Encode(ViewBag.arrayVistiors));
但是我想要像这样获取:var visitorData = {US:200,IN:123}
。请帮忙解决一下。@Zbigniew - user7918630ToDictionary
方法,例如 arrayVisitors.ToDictionary(key => key.CountryCode, value => value.VisitorsCount)
。 - ZbigniewarrayVisitors.Select(i => new { i.CountryCode, i.VisitorsCount })
。 - Zbigniew
+
编译成的String.Concat
方法支持(string, object)
重载。请参考链接:http://msdn.microsoft.com/en-us/library/system.string.concat(v=vs.71).aspx - Adam