Table of Contents
Table of Contents
Notice....................................................................................................................................................................2
19. Introduction to C# 4.0....................................................................................................................................1
19.1 Dynamic binding........................................................................................................................................1
19.2 Named and optional parameters.................................................................................................................1
19.3 COM specific interop features....................................................................................................................1
19.4 Variance..................................................................................................................................................... 1
19.5 About this document...................................................................................................................................1
20. Dynamic Binding............................................................................................................................................2
20.1 The dynamic type.......................................................................................................................................3
20.2 Dynamic binding........................................................................................................................................4
20.3 Compile time semantics of dynamic binding..............................................................................................4
20.3.1 Static binding with dynamic arguments...............................................................................................5
20.3.2 Dynamic binding with a statically known candidate set.......................................................................5
20.3.3 Conversion to interface types...............................................................................................................5
20.3.4 Dynamic collections in foreach statements..........................................................................................5
20.3.5 Dynamic resources in using statements................................................................................................6
20.3.6 Compound operators............................................................................................................................6
20.4 Runtime semantics of dynamic binding......................................................................................................7
21. Named and Optional Arguments..................................................................................................................8
21.1 Optional arguments....................................................................................................................................8
21.2 Named Arguments......................................................................................................................................9
21.3 Overload resolution..................................................................................................................................10
21.4 Better function..........................................................................................................................................10
21.5 Invocation.................................................................................................................................................11
22. COM Interoperability..................................................................................................................................12
22.1 Passing values to reference parameters.....................................................................................................12
22.2 Linking of Primary Interop Assemblies....................................................................................................13
22.3 Dynamification of Linked COM members...............................................................................................13
22.4 The COM runtime binder.........................................................................................................................13
22.5 Example.................................................................................................................................................... 13
23. Co- and Contravariance..............................................................................................................................15
23.1 Covariance................................................................................................................................................15
23.2 Contravariance..........................................................................................................................................16
23.3 Limitations...............................................................................................................................................16
23.4 Syntax.......................................................................................................................................................16
23.5 Variance safety.........................................................................................................................................17
23.6 Interface declarations................................................................................................................................17
23.6.1 Interface methods...............................................................................................................................17
23.6.2 Other interface members....................................................................................................................18
23.7 Delegate declarations................................................................................................................................18
23.8 Conversions..............................................................................................................................................18
23.8.1 Implicit conversions...........................................................................................................................18
23.8.2 Explicit conversions...........................................................................................................................19
23.9 Type Inference..........................................................................................................................................19
23.9.1 The first phase....................................................................................................................................19
23.9.2 Exact inferences.................................................................................................................................19
23.9.3 Lower-bound inferences....................................................................................................................19
23.9.4 Upper-bound inferences.....................................................................................................................20
23.9.5 Fixing.................................................................................................................................................21
Copyright
Ó
Microsoft Corporation 1999-2009. All Rights Reserved.