Free mag vol1 | Page 75

CHAPTER 1  THE PHILOSOPHY OF .NET Inclusion of a lambda operator (=>), which even further simplifies working with .NET delegate types. A new object initialization syntax, which allows you to set property values at the time of object creation. .NET 4.0 (released in 2010) updated C# yet again with a handful of features. For example: Support for optional method parameters, as well as named method arguments. Support for dynamic lookup of members at runtime via the dynamic keyword. As you will see in Chapter 18 this provides a unified approach to invoking members on the fly, regardless of which framework the member implemented (COM, IronRuby, IronPython, or via .NET reflection services). Working with generic types is much more intuitive, given that you can easily map generic data to and from general System.Object collections via covariance and contravariance. And that brings us to the current version of C# found with .NET 4.5. The current version of C# provides a pair of new keywords (async and await), which massively simplify multithreaded and asynchronous programming. If you have worked with previous versions of C#, you might recall that calling methods via secondary threads required a fair amount of cryptic code and the use of various .NET namespaces. Given that C# now supports language keywords that handle this complexity for you, the process of calling methods asynchronously is almost as easy as calling a method in a synchronous manner. Chapter 19 will cover these topics in detail. Managed vs. Unmanaged Code Perhaps the most important point to understand about the C# language is that it can produce code that can execute only within the .NET runtime (you could never use C# to build a native COM server or an unmanaged C/C++ application). Officially speaking, the term used to describe the code targeting the .NET runtime is managed code. The binary unit that contains the managed code is termed an assembly (more details on assemblies in just a bit). Conversely, code that cannot be directly hosted by the .NET runtime is termed unmanaged code. Additional .NET-Aware Programming Languages Understand that C# is not the only language that can be used to build .NET applications. Out of the box, Visual Studio provides you with five managed languages, specifically, C#, Visual Basic, C++/CLI, JavaScript, and F#.  Note F# is a .NET language based on the syntax of functional languages. While F# can be used as a purely functional language, it also has support for OOP constructs and the .NET base class libraries. If you are interested in learning more about this managed language, navigate online to the official F# homepage, http://msdn.microsoft.com/fsharp. 7