Home » C# Programming » Generics

For the code snippet shown below, which of the following statements are valid? public class Generic { public T Field; public void TestSub() { T i = Field + 1; } } class MyProgram { static void Main(string[] args) { Generic gen = new Generic(); gen.TestSub(); } }

Correct Answer: Compiler will report an error: Operator '+' is not defined for types T and int.

← Previous Question Next Question→

More Questions from Generics

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion