Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit on amount of generic parameters in .NET?

Tags:

Is there a limit on the amount of generic parameters you can have on a type in .NET? Either hard limit (like 32) or a soft limit (where it somehow effects performance to much, etc.)

What I'm referring to is:

class Foo<T0, T2, T3, T4, etc.> {
}
like image 677
thr Avatar asked Mar 26 '10 15:03

thr


People also ask

Can a generic class have multiple generic parameters?

A Generic class can have muliple type parameters.

What is the limit to the number of parameters inputs a method can have C#?

NET implementation limits the maximum number of parameters to 2^14 . CIL also stores lengths of parameter arrays in unsigned shorts, so the length can't be more than 65,535.

How many generic type parameters does the dictionary class have?

Generic. Dictionary<TKey,TValue> generic type has two type parameters, TKey and TValue , that represent the types of its keys and values.

What is generic parameters in C#?

Generics were added in C# 2.0. Generics are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types that they store or use. A generic collection class might use a type parameter as a placeholder for the type of objects that it stores.


1 Answers

From the C# 2.0 language spec

8.16.3 Multiple type parameters Generic type declarations can have any number of type parameters.

like image 130
Mark Avatar answered Sep 21 '22 03:09

Mark