Examveda

Which statement is valid for the following C# code snippet?
public class Generic<T>
{
    public T Field;
}
class Program
{
    static void Main(string[] args)
    {
        Generic<String> g = new Generic<String>();
        g.Field = "Hi";
        Console.WriteLine(g.Field);
    }
}

A. Compile time error

B. Generic being a keyword cannot be used as a class name

C. Runtime error

D. Code runs successfully

Answer: Option D


Join The Discussion

Related Questions on Delegates and Events in C Sharp