Examveda

Which of the following statements are valid in the following C# code snippet?
public class Generic<T>
{
    public T Field;
    public void testSub()
    {
        T i = Field + 1;
    }
}
class Program
{
    static void Main(string[] args)
    {
        Genericlt;int>g = new Genericlt;int>();
        g.testSub();
    }
}

A. code runs successfully but prints nothing

B. code runs successfully and prints 1

C. program will give run time error

D. compile time error

Answer: Option D


Join The Discussion

Related Questions on Delegates and Events in C Sharp