/// <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 });
}
}
我看了看其他的問題,但他們似乎略有不同,我得到的錯誤:LINQ的返回字符串數組
Cannot implicitly convert type 'System.Linq.IQueryable<string[]>' to 'string[]'
我知道這可能是簡單的,可能有人指出,什麼是錯在這裏請?
是否有特殊原因需要返回數組? IEnumerable將在大多數情況下更可取,除非調用代碼明確需要數組(不太可能) –
MattDavey