Generics & Iterators             Programming in C#                tnngo2@gmail.com
Generics
What is generics?
What is generics?      ensure type-safety             the compiler will validate types while compiling, and throw an error...
Benefits      No Casting, and Boxing      Increased Performance      Ensured strongly-typed Model      Reduced run-time er...
Namespace for Generics      System.Collection.Generic
Namespace for Generics
Implementation     https://gist.github.com/2499823
Constraints      https://gist.github.com/2505556
Inheriting generic classes
Generic Methods     virtual     override     abstract     https://gist.github.com/2507425
Generic Interfaces      https://gist.github.com/2506990
Generic Interface Constraints      https://gist.github.com/2507482
Question?     https://gist.github.com/2507914
Iterators
Iterators       is a way of navigating through the values in a collection.       specify the way values are generated when...
Benefits      Perform Simplified Iteration      Return Infinite values      Reduce Complexity      Save Memory
Implementation     https://gist.github.com/2507655
Question?     What is the difference between IEnumerator and IEnumerable?
Question?      What is the difference between IEnumerator and IEnumerable?  IEnumerable  public IEnumerator GetEnumerator(...
14   generics and iterators
Upcoming SlideShare
Loading in …5
×

14 generics and iterators

717 views
637 views

Published on

Published in: Technology, Health & Medicine
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
717
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

14 generics and iterators

  1. 1. Generics & Iterators Programming in C# tnngo2@gmail.com
  2. 2. Generics
  3. 3. What is generics?
  4. 4. 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.
  5. 5. Benefits No Casting, and Boxing Increased Performance Ensured strongly-typed Model Reduced run-time errors
  6. 6. Namespace for Generics System.Collection.Generic
  7. 7. Namespace for Generics
  8. 8. Implementation https://gist.github.com/2499823
  9. 9. Constraints https://gist.github.com/2505556
  10. 10. Inheriting generic classes
  11. 11. Generic Methods virtual override abstract https://gist.github.com/2507425
  12. 12. Generic Interfaces https://gist.github.com/2506990
  13. 13. Generic Interface Constraints https://gist.github.com/2507482
  14. 14. Question? https://gist.github.com/2507914
  15. 15. Iterators
  16. 16. 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.
  17. 17. Benefits Perform Simplified Iteration Return Infinite values Reduce Complexity Save Memory
  18. 18. Implementation https://gist.github.com/2507655
  19. 19. Question? What is the difference between IEnumerator and IEnumerable?
  20. 20. Question? What is the difference between IEnumerator and IEnumerable? IEnumerable public IEnumerator GetEnumerator(); IEnumerator public object Current; public void Reset(); public bool MoveNext();

×