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.> {
}
A Generic class can have muliple type parameters.
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.
Generic. Dictionary<TKey,TValue> generic type has two type parameters, TKey and TValue , that represent the types of its keys and values.
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.
From the C# 2.0 language spec
8.16.3 Multiple type parameters Generic type declarations can have any number of type parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With