Home / C# Programming / Generics :: Discussion

Discussion :: Generics

  1. For the code snippet given below, which of the following statements are valid?

    public class MyContainer where T: IComparabte 
    {  
       // Insert code here 
    }
    1. Class MyContainer requires that it's type argument must implement IComparabte interface.
    2. Type argument of class MyContainer must be IComparabte.
    3. Compiler will report an error for this block of code.
    4. This requirement on type argument is called as constraint.

     

  2. A.

    1 and 2 Only

    B.

    1, 2 and 3 Only

    C.

    1 and 4 Only

    D.

    All of the above

    E.

    None of the above

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    No answer description available for this question.


Be The First To Comment