O'Reilly C# 5.0 in a Nutshell, 5th Edition 9781449320102 Manual Do Utilizador

Códigos do produto
9781449320102
Página de 21
What distinguishes WinRT from ordinary COM is that WinRT projects its libraries
into a multitude of languages, namely C#, VB, C++ and JavaScript, so that each
language sees WinRT types (almost) as though they were written especially for it.
For example, WinRT will adapt capitalization rules to suit the standards of the target
language, and will even remap some functions and interfaces. WinRT assemblies
also ship with rich metadata in .winmd files which have the same format as .NET
assembly files, allowing transparent consumption without special ritual. In fact, you
might even be unaware that you’re using WinRT rather than .NET types, aside of
namespace differences. (Another clue is that WinRT types are subject to COM-style
restrictions; for instance, they offer limited support for inheritance and generics.)
WinRT/Metro does not supersede the full .NET Framework.
The  latter  is  still  recommended  (and  necessary)  for  standard
desktop  and  server-side  development,  and  has  the  following
advantages:
• Programs are not restricted to running in a sandbox.
• Programs  can  use  the  entire  .NET  Framework  and  any
third-party library.
• Application  distribution  does  not  rely  on  the  Windows
Store.
• Applications  can  target  the  latest  Framework  version
without requiring users to have the latest OS version.
What’s New in C# 5.0
C#  5.0’s  big  new  feature  is  support  for  asynchronous  functions  via  two  new
keywords, 
async
 and 
await
. Asynchronous functions enable asynchronous continu-
ations, which make it easier to write responsive and thread-safe rich-client applica-
tions. They also make it easy to write highly concurrent and efficient I/O-bound
applications that don’t tie up a thread resource per operation.
.
What’s New in C# 4.0
The features new to C# 4.0 were:
• Dynamic binding
• Optional parameters and named arguments
• Type variance with generic interfaces and delegates
• COM interoperability improvements
Dynamic binding (Chapters 
) defers binding—the process of resolving types
and members—from compile time to runtime and is useful in scenarios that would
otherwise require complicated reflection code. Dynamic binding is also useful when
interoperating with dynamic languages and COM components.
6 | Chapter 1:
Introducing C# and the .NET Framework