14 generics and iterators
DESCRIPTION
TRANSCRIPT
![Page 2: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/2.jpg)
Generics
![Page 3: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/3.jpg)
What is generics?
![Page 4: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/4.jpg)
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.
![Page 5: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/5.jpg)
![Page 6: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/6.jpg)
Benefits No Casting, and Boxing Increased Performance Ensured strongly-typed Model Reduced run-time errors
![Page 7: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/7.jpg)
Namespace for Generics System.Collection.Generic
![Page 8: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/8.jpg)
Namespace for Generics
![Page 11: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/11.jpg)
Inheriting generic classes
![Page 12: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/12.jpg)
Generic Methods virtual override abstract https://gist.github.com/2507425
![Page 16: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/16.jpg)
Iterators
![Page 17: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/17.jpg)
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.
![Page 18: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/18.jpg)
Benefits Perform Simplified Iteration Return Infinite values Reduce Complexity Save Memory
![Page 20: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/20.jpg)
Question? What is the difference between IEnumerator and IEnumerable?
![Page 21: 14 generics and iterators](https://reader034.vdocuments.net/reader034/viewer/2022052208/53fce06a8d7f7288518b48aa/html5/thumbnails/21.jpg)
Question? What is the difference between IEnumerator and IEnumerable?
IEnumerable public IEnumerator GetEnumerator(); IEnumerator public object Current; public void Reset(); public bool MoveNext();