โ Back to Interfaces
Question 621
Generic Method Constrained to an Interface
Generic Method Constrained to an Interface
Complete the generic methodMathUtil.Max<T>with the constraintwhere T : IComparable<T>. It returns the larger ofaandbusingCompareTo. Do NOT write aMainmethod. ForMax(3, 9)thenMax("apple", "banana")the program prints: 9 banana
Expected Output:
9 banana
Topics:
Interfaces
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.