Examveda

What will be the output of the following C# code?
public class Generic<T>
{
    public T Field;
}
class Program
{
    static void Main(string[] args)
    {
        Generic<int> g2 = new Generic<int>();
        Generic<int> g3 = new Generic<int>();
        g2.Field = 8;
        g3.Field = 4;
        if (g2.Field % g3.Field == 0)
        {
            Console.WriteLine("A");
        }
        else
        Console.WriteLine("Prints nothing:");
        Console.ReadLine();
    }
}

A. Compile time error

B. A

C. Run time error

D. Code runs successfully but prints nothing

Answer: Option B


Join The Discussion

Related Questions on Delegates and Events in C Sharp