private static void Main(string[] args)
{
var query = Data();
}
private static IList<Employee> Data()
{
List<Employee> list = new List<Employee>();
list.Add(new Employee { Name = "test0", Age = 19 });
list.Add(new Employee { Name = "test1", Age = 33 });
list.Add(new Employee { Name = "test2", Age = 25 });
return list;
}
private static IEnumerable<Employee> Data()
{
List<Employee> list = new List<Employee>();
list.Add(new Employee { Name = "test0", Age = 19 });
list.Add(new Employee { Name = "test1", Age = 33 });
list.Add(new Employee { Name = "test2", Age = 25 });
return list;
}
When I run code above, I didn't see any different result when result type in
IEnumerable
or IList
. Is there any different using both of them? How to decide which type to use?