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 (20)

C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
 
C# Delegates and Event Handling
C# Delegates and Event HandlingC# Delegates and Event Handling
C# Delegates and Event Handling
 
C# Constructors
C# ConstructorsC# Constructors
C# Constructors
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism Java
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Delegates and events
Delegates and events   Delegates and events
Delegates and events
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections framework
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Learn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsLearn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & Methods
 
Java collection
Java collectionJava collection
Java collection
 
Object and class
Object and classObject and class
Object and class
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Delegates in C#
Delegates in C#Delegates in C#
Delegates in C#
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 

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 (9)

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
 
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
 
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
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 

More from Raghuveer Guthikonda (6)

C# String
C# StringC# String
C# String
 
Operators & Casts
Operators & CastsOperators & Casts
Operators & Casts
 
Arrays C#
Arrays C#Arrays C#
Arrays 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

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

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