Difficulty: Easy
Correct Answer: Generics provide type safety without the overhead of multiple implementations.
Explanation:
Introduction / Context:
Generics in .NET enable strongly typed algorithms and collections without sacrificing performance or requiring a separate implementation for each type. This item asks for the primary benefit.
Given Data / Assumptions:
Concept / Approach:
Generics centralize an algorithm in a single implementation parameterized by type. The compiler enforces type safety, eliminating many casts. Because value types are stored without boxing in generic collections, performance improves. Generics do not make all runtime errors impossible, but they reduce a class of type-mismatch errors.
Step-by-Step Solution:
Verification / Alternative check:
Compare ArrayList (non-generic) vs. List
Why Other Options Are Wrong:
They contradict the fundamental purpose of generics or overclaim their guarantees.
Common Pitfalls:
Assuming generics are merely syntactic sugar; they materially improve safety and performance.
Final Answer:
Generics provide type safety without the overhead of multiple implementations.
Discussion & Comments