【发布时间】:2011-09-09 12:30:20
【问题描述】:
/// <summary>
/// Returns list of popular searches
/// </summary>
public static string[] getPopularSearches(int SectionID, int MaxToFetch)
{
using (MainContext db = new MainContext())
{
return (from c in db.tblSearches where c.SectionID == SectionID && c.Featured select new[] { c.Term });
}
}
我查看了其他问题,但它们似乎略有不同,我得到了错误:
Cannot implicitly convert type 'System.Linq.IQueryable<string[]>' to 'string[]'
我知道这可能很简单,有人可以指出这里有什么问题吗?
【问题讨论】:
-
是否有特殊原因需要返回数组?在大多数情况下,IEnumerable
会更可取,除非调用代码特别需要一个数组(不太可能)
标签: c# asp.net arrays string linq