What Will Be The Output Of The Following C Codep Pre Langcsharp #634
What will be the output of the following C# code?</p> <pre><code class="language-csharp" line="1"> 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(); } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Delegates, Generics and LINQ - Generic Methods - Quiz No.1.
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(); } }
Compile time error
A
Run time error
Code runs successfully but prints nothing