Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Employee
- {
- public int Id { get; set; }
- public string Name { get; set; }
- }
- IList<Employee> EmpList ;
- Or
- List<Employee> EmpList ;
- IList<Employee> EmpList = new List<Employee>();
- List<Employee> EmpList = new List<Employee>();
- var EmpList = new List<Employee>(); // EmpList is List<Employee>
- IList<Employee> EmpList = new IList<Employee>();
- public void IterateEmployees(IEnumerable<Employee> employees)
- {
- foreach(var employee in employees)
- {
- // ...
- }
- }
- //this will not compile
- IList<Employee> EmpList = new IList<Employee>();
- //this is what you're really looking for:
- List<Employee> EmpList = new List<Employee>();
- //but this will also compile:
- IList<Employee> EmpList = new List<Employee>();
- [SerializableAttribute]
- public class List<T> : IList<T>, ICollection<T>,
- IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>,
- IEnumerable
Add Comment
Please, Sign In to add comment