using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public delegate bool IsValid(EMP objEmp);
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<EMP> obj = new List<EMP>();
obj.Add(new EMP() { Name = "Ajay", Salary = 4000, Experience = 4 });
obj.Add(new EMP() { Name = "Amit", Salary = 4000, Experience = 4 });
obj.Add(new EMP() { Name = "Anil", Salary = 11000, Experience = 4 });
IsValid objIsValid = x => x.Salary > 3000;
List<EMP> list = EMP.IsValidated(obj, objIsValid);
foreach (EMP oEmp in list)
{
Response.Write(oEmp.Name);
}
}
}
public class EMP
{
public string Name { get; set; }
public int Salary { get; set; }
public int Experience { get; set; }
public static List<EMP> IsValidated(List<EMP> objEmp, IsValid del)
{
List<EMP> objK = objEmp.Select(del);
return objK;
}
}
Following error is coming
The type arguments for method 'System.Linq.Enumerable.Select<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,int,TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.