Florin Olariu: "Alexandru Ioan Cuza", University of Iași Department of Computer Science
Florin Olariu: "Alexandru Ioan Cuza", University of Iași Department of Computer Science
NET
Florin Olariu
“Alexandru Ioan Cuza”, University of Iași
Department of Computer Science
Agenda
Generic dictionaries
Demo
LINQ
Demo
Interview questions
What’s next …
What is a dictionary?
How can we manipulate a dictionary?
Generic dictionaries
What is a dictionary?
What is a dictionary?
What is a dictionary?
What is a dictionary?
What is a dictionary?
What is a dictionary?
Declaration
Generic dictionaries
Declaration
Dictionary<TKey, TValue>
Generic dictionaries
Declaration
Dictionary<TKey, TValue>
Samples
Dictionary<int, int>
Dictionary<int, string>
Dictionary<string, Product>
Generic dictionaries
Initialization
Dictionary<string, string> states;
states = new Dictionary<string, string>();
Manipulating a dictionary
states.Add("NY", "New York");
Demo
Generic dictionaries
Performance
Generic dictionaries
Performance
Many collection classes offer the same functionality as others; for example,
SortedList offers nearly the same features as SortedDictionary.
Generic dictionaries
Performance
Many collection classes offer the same functionality as others; for example,
SortedList offers nearly the same features as SortedDictionary.
However, often there’s a big difference in performance. Whereas one collection
consumes less memory, the other collection class is faster with retrieval of
elements.
Generic dictionaries
Details about big O algorithm complexity in attached pdf for the course.
LINQ
LINQ
Intro
Building a LINQ query using Query syntax - Demo
Building a LINQ query using Method syntax - Demo
Lambda expression in action - Demo
Using LINQ with collections
LINQ
Delegate
LINQ
Delegate
Is a type that represents a reference to a method with a specific parameter
list and a return type.
LINQ
Delegate
Is a type that represents a reference to a method with a specific parameter
list and a return type.
LINQ
Delegate
Is a type that represents a reference to a method with a specific parameter
list and a return type.
LINQ
Lambda expression
LINQ
Lambda expression
Is a method that can be passed as an argument to a method when that
argument is expecting a delegate type.
LINQ
DO AVOID
Use LINQ! Iterating the collections multiple
times
Consider using method syntax over Use FirstOrDefault and LastOrDefault
query syntax instead of First and Last
Wait to cast a result after all queries
are defined
Interview questions
One more thing…
“Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live”
― John Woods
Questions