7. Covariance Defined Let’s say S is subtype of B and GT is a generic type GT<S> behaves like subtype of GT<B> on assignment compatibility, i.e. GT<S> s = … GT<B> b = s; GT<S> s = (GT<S>)b; Safe only when GT doesn’t expose members “receiving” T as input (aka input-safe) Microsoft Confidential 7
9. Contravariance Defined Let’s say S is subtype of B and GT is a generic type GT<B> behaves like subtype of GT<S> on assignment compatibility, i.e. GT<B> b = … GT<S> s = b; GT<B> b = (GT<B>)s; Safe only when GT doesn’t expose members “returning” T as output (aka output-safe) Microsoft Confidential 9
13. ?Quiz A method summing Length properties of all parameters, regardless of actual type
14. ?Quiz How to builds C# objects that behave like JavaScript objects, i.e. members can be added at any time?
15. ?Quiz Write a class whose objects can invoke static methods of any particular type Bonus #1: include non-public static methods Bonus #2: ignore case
16. ?Quiz Write a class whose objects can be used as result-caching proxy for the method invocation of any other object
18. ?Quiz Write a method calculating Fibonacci number using a thread in thread-pool and returning result to caller
19. Task Parallelism Features Wait on tasks Support parent-child relationship Exception handling Cancelling tasks Continuation Execute one task after another Microsoft Confidential 19
20. ?Quiz Write 3 methods: Calculate some known Fibonacci numbers Calculate Fibonacci numbers for a range Calculate Fibonacci numbers for a list of specified indexes Each calculation must take place in a thread in thread-pool
21. Parallel Class Assign delegates to a handful of Task instances, not one-to-one mapping
22. ?Quiz Write a method which calculate some specified Fibonacci numbers and return the sum of them to the caller