【发布时间】:2016-08-24 14:54:04
【问题描述】:
我在 MVC 中使用 checkboxes。我有一个表,其中一列为bit 类型。下面的代码给了我一个错误。
[HttpPost]
public string Index(IEnumerable<City> cities)
{
if (cities.Count(x => x.Chosen) == 0)
{
return "You did not select any city";
}
......
}
Chosen 在这里是一个位类型。当我尝试构建它时说:
不能隐式转换类型'bool?' '布尔'。明确的 存在转换(您是否缺少演员表?)
【问题讨论】:
-
x.Chosen是bool?的类型吗?
标签: asp.net-mvc