| |
|
What are main drawback of generics in cSharp? Question Posted on 14 Aug 2022 Home >> DotNet >> C# >> What are main drawback of generics in cSharp? |
What are main drawback of generics in cSharp?
Below are the main drawback of generics in c#:-
(1)Lightweight dynamic methods cannot be generic.
(2)Generics cannot be used with enumerations and enumerations can not have generic type parameters. And enumeration can be generic only incidentally. To understand this we will take example of because it is nested in a generic type that is defined using Visual Basic, C#, or C++.
(3)The .NET framework will not support context-bound generic types to ger more details we will explain more deeply here as Generic types can be derived from most base classes like MarshalByRefObject(Here we used constraints to require that generic type parameter derive from base calsses like marshalByRefObject). Now come to context-bound generic types a generic type can be derived from ContextBoundObject, but trying to create an instance of that type causes a TypeLoadException.
(4)In C++, C# and visual Basic nested type is enclosed in generic type and cannot be instantiated unless type have been assigned to type parameters of all enclosing types. | |
|
|
|
|