i need Enumarable value from below class but give error
public static Enumerable LoadDataByName(string name)
{
List<StuffDepartman> Stuff = (List<StuffDepartman>)HttpContext.Current.Session["Stuffs"];
var stuffs = from s in Stuff select s;
stuffs = from s in Stuff where s.Name = name select s.Name;
return stuffs.AsEnumerable();
}
But Give me error: System.Linq.Enumerable’: static types cannot be used as return types
In .NET 3.5, there exists a static
Enumerableexisting inSystem.Linq, which contains extension methods for manipulatingIEnumerables – this is not what you want to (or clearly can) return. Change it toIEnumerable, which is the non-generic enumerable class (and what I think you intend), and all should work fine.Even better, use the generic version of
IEnumerable, as such:Also, note that you don’t need the call to
AsEnumerablebefore returning, sinceList<T>implementsIEnumerable<T>, and the former can be implicitly casted to the latter. The=needed to be changed to==, since you want to use the equality rather than assigment operator here. The other changes are just tidying up.