Home / C# Programming / Generics :: Discussion

Discussion :: Generics

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

    public class GenericT> 
    {   
      public T Field;   
      public void TestSub()    
        {        
            T i = Field + 1;    
        } 
     } 
     class MyProgram 
     {   
         static void Main(string[] args)      
         {      
            Genericint> gen = new Genericint>();         
            gen.TestSub();  
         }
     }
    

     

  2. A.

    Addition will produce result 1.

    B.

    Result of addition is system dependent.

    C.

    Program will generate run- time exception

    D.

    Compiler will report an error: operator'+' is not defined for types T and int.

    E.

    None of the above.

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    No answer description available for this question.


Be The First To Comment