List<T>
The List<T> represents a strongly typed collection of objects which is highly optimized for providing maximum performance and can be accessed using an index.
This class provides methods to loop, filter, sort and manipulate collections.
The non-generic version of this class is the ArrayList class.
2. What is List<T>???
• The List<T> represents a strongly typed
collection of objects which is highly optimized
for providing maximum performance and can
be accessed using an index.
• This class provides methods to loop, filter, sort
and manipulate collections.
• The non-generic version of this class is the
ArrayList class.
5. Lambda Expression
• A lambda expression is an anonymous function
and it is mostly used to create delegates
• Lambda basic definition: Parameters => Executed
code.
• Example:- n => n % 2 == 1
n is the input parameter
n % 2 == 1 is the expression
You can read this as: "input parameter named n
goes to anonymous function which returns true if
the input is odd".
6. Filtering List<T> using a single
condition - (Age > 35)
List<Person> filterOne = pList.FindAll(p=>p.Age > 35);
7. Filtering List<T> on multiple conditions
(Age > 35 and Sex is Female)
List<Person> filterOne = pList.FindAll(p=>p.Age > 35
&& p.Sex==‘F’);