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();
}
}
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