.NET Framework generics — Which statements are valid? 1) Generics is a language feature. 2) We can create a generic class, however, we cannot create a generic interface in C#.NET. 3) Generic delegates are not allowed in C#.NET. 4) Generics are useful in collection classes in the .NET Framework. 5) None of the above.

Difficulty: Easy

Correct Answer: 1 and 4 Only

Explanation:


Introduction / Context:
This question checks fundamental facts about generics across the C# language and the .NET class libraries, especially interfaces, delegates, and collections.



Given Data / Assumptions:

  • We evaluate four claims about generics; item 5 is a distractor.
  • We consider standard C# and the Base Class Library.


Concept / Approach:
(1) True: Generics are a language (and CLR) feature enabling parameterized types. (2) False: C# supports generic interfaces, e.g., IEnumerable, IComparer. (3) False: Generic delegates are allowed, e.g., Func, Action. (4) True: Collections such as List, Dictionary rely on generics for safety and performance.



Step-by-Step Solution:

Mark 1 as true.Mark 2 as false (many generic interfaces exist).Mark 3 as false (Func/Action are generic delegates).Mark 4 as true (generics power most collections).Therefore, the correct grouping is 1 and 4 only.


Verification / Alternative check:
Open any project and use IEnumerable, List, and Action to see generic interfaces and delegates in action.



Why Other Options Are Wrong:
They include false statements 2 and/or 3, or claim all/none are correct.



Common Pitfalls:
Confusing earlier .NET 1.x collections (non-generic) with the generic collections introduced later.



Final Answer:
1 and 4 Only

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion