1 / 8

Generics

Generics. Samar Samy FCI-Helwan University Microsoft Student Partner – Microsoft Egypt . Microsoft Tech-Club Helwan Univ. – Technical Dept. What are Generics ??. - Generics are the most powerful feature of C# 2.0 . - Generics allow you to define type-safe data structures, .

kaden
Download Presentation

Generics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generics Samar Samy FCI-Helwan University Microsoft Student Partner – Microsoft Egypt . Microsoft Tech-Club Helwan Univ. – Technical Dept.

  2. What are Generics ?? - Generics are the most powerful feature of C# 2.0. - Generics allow you to define type-safe data structures,

  3. Before Generics : Using System.Collections; Stack s = new Stack(); s.Push(7); Int x = (int)s.pop();

  4. With Generics: Using Sysytem.Collections.Generics; Stack <int> s = new Stack<int>(); s.Push(7); // no castInt x = s.pop

  5. 2 Benefits Of Generics 2 Benefits of Generics

  6. Type Safe Using System.Collections; Stack s = new Stack(); s.Push(7); s.push(“seven”); object O = s.pop(); // Now what ????? Using System.Collections.Generics; Stack <int>s = new Stack<int>(); s.Push(7); //compile-time Errors.push(“seven”);

  7. Performance: Boxing and Unboxing : If we wrote : int i = 123 ; Object o = i ; // Boxing int j=(int) o ; // unboxing

  8. Thanks You can contact me at: eng_samar95@yahoo.com eng.samar_fci@yahoo.com Blog : http://samarsamy.wordpress.com/ Samar Samy FCI-Helwan University Microsoft Student Partner – Microsoft Egypt . Microsoft Tech-Club Helwan Univ. – Technical Dept.

More Related