Quantcast
Channel: 2,000 Things You Should Know About C# » Type Parameters
Browsing latest articles
Browse All 7 View Live

Image may be NSFW.
Clik here to view.

#542 – Conventions for Naming Type Parameters

You can name type parameters in generic classes and generic methods anything you like.  But you should typically follow the following naming conventions for naming type parameters: Use a short...

View Article



Image may be NSFW.
Clik here to view.

#545 – Specifying Constraints for More than One Type Parameter

When specifying constraints for type parameters in a generic class, you can specify constraints for more than one parameter. To specify more than one constraint, just place each constraint on a...

View Article

Image may be NSFW.
Clik here to view.

#547 – Things That Can Serve as Type Parameter Constraints

A constraint on a type parameter is often a base class or interface, but can actually take on a number of different forms. A constraint can be a class type: // Type parameter can be some subclass of...

View Article

Image may be NSFW.
Clik here to view.

#548 – No More Than One Class for a Type Parameter Constraint

When specifying constraints for a type parameter in a generic class, you can specify at most one class as a constraint, but  you can specify one or more interfaces.  If one of the constraints is a...

View Article

Image may be NSFW.
Clik here to view.

#1,027 – Type Parameters vs. Type Arguments in a Generic Class

A generic class is a class that takes one or more type parameters, which it then uses in the definition of the class.  It can be thought of as a template for a class. Type parameters are used in the...

View Article


Image may be NSFW.
Clik here to view.

#1,035 – Summary of Type Parameter Constraints

Here’s a quick summary of the different types of constraints that you can apply to type parameters: Require parameter’s type to derive from a specified class: where T : [base-class] Require parameter’s...

View Article

Image may be NSFW.
Clik here to view.

#1,064 – Getting Around Inability to Explicitly Convert Type Parameters

You can’t explicitly convert a type parameter to either a value type or a reference type (you can convert to an interface). To get around this restriction, you can use the as operator on the type...

View Article
Browsing latest articles
Browse All 7 View Live




Latest Images