Introduction What the generic. What are the Generic types : - Class - Methods Type of coding the generic method. - Using the generic method within non-generic class - Using the generic method within generic class Features of Generics - Example for Generic What is the main different between the generic and non-generic class. What is the main different between the generic and non-generic methods. outline
Generics are the most powerful feature of C#. Generics allow you to define type-safe data structures, without committing to actual data types. This results in a significant performance boost and higher quality code, because you get to reuse data processing algorithms without duplicating type-specific code. Introduction
What the generic? allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program. In other words, generic allow you to write a class or method that can work with any data type. You write the specifications for the class or the method, with substitute parameters for data types. When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type. What the generic
What are the Generic types : Class Methods Generic types
Generics types
- The easy way to write the generic class is :- class nameclass { } - We can use the variable with type of public T students; Generics types
Type of coding the generic method
Features of Generics
1- code the class EXAMPLE
2- code the button1((int)) 3- code the button2 ((char)) EXAMPLE
What is the main different between the generic and non-generic class? Generic class:- 1- This class can operate on any kind of object. 2- These objects each can operate on different type of data. Different between the generic and non-generic class.
Different between the generic and non-generic methods