作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Controller Action ,如:
Public ActionResult MyAction(int[] stuff){}
$.getJSON(url, { stuff: [] })
int[] stuff = {0};
)。
最佳答案
我认为这是MVC中的一个错误:
// create a vpr with raw value and attempted value of empty string
ValueProviderResult r = new ValueProviderResult("", "", System.Globalization.CultureInfo.CurrentCulture);
// this next line returns {0}
r.ConvertTo(typeof(int[]));
// case 2: destination type is array but source is single element, so wrap element in array + convert
object element = ConvertSimpleType(culture, value, destinationElementType);
IList converted = Array.CreateInstance(destinationElementType, 1);
converted[0] = element;
return converted;
converted[0]
成为元素,并且 ConvertSimpleType 将 ""强制转换为 0。所以我要结束这个问题,除非有人有更多信息。
关于带有空数组的 ASP.NET MVC Int Array 参数默认为 {0},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4036329/
我是一名优秀的程序员,十分优秀!