Retry an async call in C#

C# interview exercise on Async & Generics, difficulty 3 of 3. Solve it in the editor beside a worked example; the tests run the moment you do.

Write Retry<T>(action, attempts) that awaits action until it succeeds or it has been tried attempts times; the last exception then reaches the caller unchanged. action is always tried at least once.

Each exercise pairs a worked example with a twin problem to solve in a real editor; the tests run the moment you do. Progress is saved in your browser, and in your account if you sign in.

More Async & Generics in C#

All C# exercises · Other languages and frameworks