SlideShare a Scribd company logo
1 of 11
Generics
Generics Overview
Generic Class
Generic interfaces
Generic Structs
Generic Methods
Generics Overview
 Generics introduce to the .NET Framework the
  concept of type parameters, which make it possible to
  design classes and methods that defer the
  specification of one or more types until the class or
  method is declared and instantiated by client code.

 The .NET Framework class library contains several
  new generic collection classes in the
  System.Collections.Generic namespace.

 Generics allow you to define type-safe classes
  without compromising type safety, performance, or
  productivity.
Generics Overview
 We use generic types to maximize Code Reuse, Type
  Safety, Performance, and Code Bloat.
 Generics Features
   Default Values
     It is not possible to assign null to generic type
     You can use default keyword to initialize default (Either 0 or null) value.
   Constraints
     If Generic Class needs to invoke some methods from the generic type,
      you have to add constraints.
   Inheritance
     A generic type can implement a generic interface.
     When deriving from a generic base class, you must provide a type
      argument instead of the base-class's generic type parameter.
   Static Members
     Static Members of generic class are only shared with one instantiation of
      the class.
Generic Class
 Generic classes encapsulate operations that are not
  specific to a particular data type.
 The most common use for generic classes is with
  collections like linked lists, hash tables, stacks, queues,
  trees, and so on.
 Operations such as adding and removing items from the
  collection are performed in basically the same way
  regardless of the type of data being stored.
 Syntax:
      public class ClassName<T>
      {//Class Members………………}
Generic Class
 Constraints:
   When you define a generic class, you can apply restrictions
    to the kinds of types that client code can use for type
    arguments when it instantiates your class.
     EX:
      class EmployeeList<T> where T : Employee, IEmployee,
      System.IComparable<T>, new()
      { // ... }
 You can apply constraints to multiple parameters, and
  multiple constraints to a single parameter.
Generic Interfaces
 Generic Interfaces
    It is often useful to define interfaces either for generic
     collection classes, or for the generic classes that
     represent items in the collection.
    We use generic interfaces to avoid boxing and
     unboxing operations on value types.
    The .NET Framework class library defines several
     generic interfaces for use with the collection classes in
     the System.Collections.Generic namespace.
Generic Interfaces
 Covariance and Contra-variance in Generics
    Covariant and contra-variant generic type parameters
     provide greater flexibility in assigning and using
     generic types.
    For example, covariant type parameters enable you to
     make assignments that look much like ordinary
     polymorphism.
 Covariance with Generic Interface
    A generic Interface is Covariant if the type is
     annotated with out keyword.
 Contra-variance with Generic Interface
     A generic Interface is Contra-variant if the type is annotated
      with in keyword.
Generic Structs
 Generic Structs
   Similar to Classes structs can be generic as well.
   They are similar to generic classes with the
    exception of inheritance features.
   Ex:
     public struct Nullable<T>
     {//…….}
Generic Methods
 Generic Methods
    A generic method is a method that is declared with type
     parameters, as follows:
       static void Swap<T>(ref T lhs, ref T rhs)
       {
          T temp;
         temp = lhs;
         lhs = rhs;
         rhs = temp;
      }
 You can define method-specific generic type parameters
  even if the containing class does not use generics at all
Generic Methods with
  Constraints
 We can have Constraints on methods also.
 When a method defines its own generic type
  parameters, it can also define constraints for these
  types.
     public void SomeMethod<T>(T t ) where T : IComparable<T>
      {...}
 You cannot provide method-level constraints for class-
  level generic type parameters. All constraints for class-
  level generic type parameters must be defined at the
  class scope.
Generic Delegates
 A delegate defined in a class can take advantage of
 the generic type parameter of that class. For
 example:
   Ex:
     public delegate void Del<T>(T item);
     public static void Notify(int i) { }
     Del<int> m1 = new Del<int>(Notify);
 Generic Methods Specialization
     Generic methods can be overloaded to define specializations
      for specific types.
     This is true for methods with generic parameters as well.

More Related Content

What's hot

What's hot (20)

6. static keyword
6. static keyword6. static keyword
6. static keyword
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Templates in c++
Templates in c++Templates in c++
Templates in c++
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
DOT Net overview
DOT Net overviewDOT Net overview
DOT Net overview
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
OOP java
OOP javaOOP java
OOP java
 
Date and Time Module in Python | Edureka
Date and Time Module in Python | EdurekaDate and Time Module in Python | Edureka
Date and Time Module in Python | Edureka
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 

Viewers also liked

Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threadsrchakra
 
Multi threading design pattern
Multi threading design patternMulti threading design pattern
Multi threading design patternYan Wang
 
C# Advanced L04-Threading
C# Advanced L04-ThreadingC# Advanced L04-Threading
C# Advanced L04-ThreadingMohammad Shaker
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and JavaSasha Goldshtein
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101Tim Penhey
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done rightPlatonov Sergey
 
Threading in c#
Threading in c#Threading in c#
Threading in c#gohsiauken
 

Viewers also liked (11)

Delegates and events
Delegates and events   Delegates and events
Delegates and events
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threads
 
Multi threading design pattern
Multi threading design patternMulti threading design pattern
Multi threading design pattern
 
C# Advanced L04-Threading
C# Advanced L04-ThreadingC# Advanced L04-Threading
C# Advanced L04-Threading
 
Collections in-csharp
Collections in-csharpCollections in-csharp
Collections in-csharp
 
Multithreading Design Patterns
Multithreading Design PatternsMultithreading Design Patterns
Multithreading Design Patterns
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and Java
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done right
 
Threading in c#
Threading in c#Threading in c#
Threading in c#
 

Similar to Generics C# (20)

Generics
GenericsGenerics
Generics
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
 
Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in java
 
LectureNotes-02-DSA
LectureNotes-02-DSALectureNotes-02-DSA
LectureNotes-02-DSA
 
SOEN6441.generics.ppt
SOEN6441.generics.pptSOEN6441.generics.ppt
SOEN6441.generics.ppt
 
Generics
GenericsGenerics
Generics
 
Lecture 8 Library classes
Lecture 8 Library classesLecture 8 Library classes
Lecture 8 Library classes
 
Generics
GenericsGenerics
Generics
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
 
.Net F# Generic class
.Net F# Generic class.Net F# Generic class
.Net F# Generic class
 
C# program structure
C# program structureC# program structure
C# program structure
 
java tutorial 4
 java tutorial 4 java tutorial 4
java tutorial 4
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Csharp generics
Csharp genericsCsharp generics
Csharp generics
 
Generic programming in java
Generic programming in javaGeneric programming in java
Generic programming in java
 

More from Raghuveer Guthikonda (7)

C# String
C# StringC# String
C# String
 
Operators & Casts
Operators & CastsOperators & Casts
Operators & Casts
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Regex in C#
Regex in C#Regex in C#
Regex in C#
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Generics C#

  • 1. Generics Generics Overview Generic Class Generic interfaces Generic Structs Generic Methods
  • 2. Generics Overview  Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code.  The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace.  Generics allow you to define type-safe classes without compromising type safety, performance, or productivity.
  • 3. Generics Overview  We use generic types to maximize Code Reuse, Type Safety, Performance, and Code Bloat.  Generics Features  Default Values  It is not possible to assign null to generic type  You can use default keyword to initialize default (Either 0 or null) value.  Constraints  If Generic Class needs to invoke some methods from the generic type, you have to add constraints.  Inheritance  A generic type can implement a generic interface.  When deriving from a generic base class, you must provide a type argument instead of the base-class's generic type parameter.  Static Members  Static Members of generic class are only shared with one instantiation of the class.
  • 4. Generic Class  Generic classes encapsulate operations that are not specific to a particular data type.  The most common use for generic classes is with collections like linked lists, hash tables, stacks, queues, trees, and so on.  Operations such as adding and removing items from the collection are performed in basically the same way regardless of the type of data being stored.  Syntax: public class ClassName<T> {//Class Members………………}
  • 5. Generic Class  Constraints:  When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class.  EX: class EmployeeList<T> where T : Employee, IEmployee, System.IComparable<T>, new() { // ... }  You can apply constraints to multiple parameters, and multiple constraints to a single parameter.
  • 6. Generic Interfaces  Generic Interfaces  It is often useful to define interfaces either for generic collection classes, or for the generic classes that represent items in the collection.  We use generic interfaces to avoid boxing and unboxing operations on value types.  The .NET Framework class library defines several generic interfaces for use with the collection classes in the System.Collections.Generic namespace.
  • 7. Generic Interfaces  Covariance and Contra-variance in Generics  Covariant and contra-variant generic type parameters provide greater flexibility in assigning and using generic types.  For example, covariant type parameters enable you to make assignments that look much like ordinary polymorphism.  Covariance with Generic Interface  A generic Interface is Covariant if the type is annotated with out keyword.  Contra-variance with Generic Interface  A generic Interface is Contra-variant if the type is annotated with in keyword.
  • 8. Generic Structs  Generic Structs  Similar to Classes structs can be generic as well.  They are similar to generic classes with the exception of inheritance features.  Ex: public struct Nullable<T> {//…….}
  • 9. Generic Methods  Generic Methods  A generic method is a method that is declared with type parameters, as follows: static void Swap<T>(ref T lhs, ref T rhs) { T temp; temp = lhs; lhs = rhs; rhs = temp; }  You can define method-specific generic type parameters even if the containing class does not use generics at all
  • 10. Generic Methods with Constraints  We can have Constraints on methods also.  When a method defines its own generic type parameters, it can also define constraints for these types.  public void SomeMethod<T>(T t ) where T : IComparable<T> {...}  You cannot provide method-level constraints for class- level generic type parameters. All constraints for class- level generic type parameters must be defined at the class scope.
  • 11. Generic Delegates  A delegate defined in a class can take advantage of the generic type parameter of that class. For example:  Ex: public delegate void Del<T>(T item); public static void Notify(int i) { } Del<int> m1 = new Del<int>(Notify);  Generic Methods Specialization  Generic methods can be overloaded to define specializations for specific types.  This is true for methods with generic parameters as well.

Editor's Notes

  1. With C# generics, the compiler compiles the generic code into IL independent of any type arguments that the clients will use. As a result, the generic code could try to use methods, properties, or members of the generic type parameters that are incompatible with the specific type arguments the client uses. This is unacceptable because it amounts to lack of type safety. In C# you need to instruct the compiler which constraints the client-specified types must obey in order for them to be used instead of the generic type parameters