TypeParameters is a generic class in C# which allows the user to create a class that can work with different types of data. This class takes a type parameter T which can be replaced with any valid data type at runtime. This helps to avoid code duplication and increases the reusability of the code.
Add method in TypeParameters class is used to add elements to the list. It takes a single parameter of type T and adds it to the list.
Example 1:
TypeParameters tp = new TypeParameters(); tp.Add(10); tp.Add(20); tp.Add(30);
Here, the TypeParameters class is created with a type parameter of int. Three elements, 10, 20, and 30, are added to the list using the Add method.
Example 2:
TypeParameters tp = new TypeParameters(); tp.Add("hello"); tp.Add("world"); tp.Add("!");
Here, the TypeParameters class is created with a type parameter of string. Three elements, "hello", "world", and "!" are added to the list using the Add method.
Package library: System.Collections.Generic.
C# (CSharp) TypeParameters.Add - 18 examples found. These are the top rated real world C# (CSharp) examples of TypeParameters.Add extracted from open source projects. You can rate examples to help us improve the quality of examples.