Generics
Date: Jan 2014
Level: Basic


INTERVIEW QUESTIONS

Company: Citrix Systems, Inc
Question Title: Generics
Language: C++
QUESTION DETAILS:

What are generics? How do you call a generic method in C++/C#? What are the disadvantages of generics?


1. Generic methods/classes accepts Generic parameters mostly denoted as parameter T, for example a generic method accepting two arguments and performing Addition operation. We can pass int, float, double etc, data type to this generic method and it will perform the same operation and will return the results. It means the methods operation is not dependent on a particular data type, hence called as a generic method.

2. The disadvantage of Generic method is that, it require Boxing (converting value type to object) and Unboxing (converting object type to value type), hence consume more resources and memory and impact the performance.
All Questions