我想在C#MVC4項目中與WebGrid交手。下面的代碼給出了這樣的錯誤...在C#中瞭解WebGrid#
編譯器錯誤信息:CS1502:爲 「System.Web.Helpers.WebGrid.WebGrid(System.Collections.Generic.IEnumerable, 系統的最佳重載的方法匹配。 Collections.Generic.IEnumerable,字符串,整數,布爾, 布爾,字符串,字符串,字符串,字符串,字符串,字符串,字符串)」有 一些無效參數
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
@{
List<int> obj1 = new List<int>(){ 1, 2, 3, 4 };
var obj1_i = (IEnumerable<int>)obj1;
var grid = new WebGrid(obj1_i);
}
</head>
<body>
<div>
@grid.GetHtml()
</div>
</body>
</html>
您是否嘗試過它,而不投地的IEnumerable''? '列表'應該實現'IEnumerable '。 –
asymptoticFault
@asymptoticFault,是的,我得到了同樣的錯誤。 – spiderplant0