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

1 thought on “Which statement is valid for the following C# code snippet?”

Leave a Comment