Generics checkpoint
Challenge on lesson: Checkpoint: generics
CHALLENGE
Difficulty: advanced+25 XP
Define interface IShape<TSelf> where TSelf : IShape<TSelf> with static abstract string Name { get; } and static abstract double Area(double side);. Implement struct Square : IShape<Square> (Area = side*side) and struct Circle : IShape<Circle> (Area = π·side² using Math.PI). Then implement static double AreaOf<T>(double side) where T : IShape<T> => T.Area(side); in class Solution.
Press Submit to check your solution.
Back to lesson: Checkpoint: generics