C# Programming - Generics - Discussion

Discussion Forum : Generics - General Questions (Q.No. 6)
6.
For the code snippet given below, which of the following statements is valid?
public class Generic<T>
{
    public T Field;
}
class Program
{
    static void Main(string[ ] args)
    {
        Generic<String> g = new Generic<String>();
        g.Field = "Hello";
        Console.WriteLine(g.Field);
    }
}
It will print string "Hello" on the console.
Name Generic cannot be used as a class name because it's a keyword.
Compiler will give an error.
Member Field of class Generic is not accessible directly.
None of the above.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.