14 generics and iterators
Post on 26-Aug-2014
746 Views
Preview:
DESCRIPTION
TRANSCRIPT
Generics & Iterators
tnngo2@gmail.com
Programming in C#
Generics
What is generics?
What is generics? ensure type-safety the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable.
Benefits No Casting, and Boxing Increased Performance Ensured strongly-typed Model Reduced run-time errors
Namespace for Generics System.Collection.Generic
Namespace for Generics
Inheriting generic classes
Generic Methods virtual override abstract https://gist.github.com/2507425
Iterators
Iterators is a way of navigating through the values in a collection. specify the way values are generated when the foreach statement accesses the elements within a collection.
Benefits Perform Simplified Iteration Return Infinite values Reduce Complexity Save Memory
Question? What is the difference between IEnumerator and IEnumerable?
Question? What is the difference between IEnumerator and IEnumerable?
IEnumerable public IEnumerator GetEnumerator(); IEnumerator public object Current; public void Reset(); public bool MoveNext();
top related