2010-06-23
| Rate This Article: | Add This Article To: |
You can see the original article in its entirety at Visual Studio Magazine-
While .NET 3.0 and 3.5 were great additions to the .NET framework, they were built against the 2.0 Common Language Runtime (CLR). Now, Microsoft has released .NET 4 – in addition to a new CLR, we've got a ton of framework and language improvements. We'll cover some of those changes here and will continue to cover .NET 4 in future articles.
C# Language
Let's start by covering a few of the new
features of the C# language. After that, we'll check out some IDE
enhancements to make your C# development experience more productive.
Named and Optional Arguments
With support for named
arguments, you can reduce the amount of typing you need to do when
calling a method (or indexer, constructor or delegate).
Dynamic keyword
The "dynamic" keyword allows you to define a
type that has its type checking done at runtime rather than compile
time. Why would you want to wait until runtime to do your type checking?
It allows your application to be more flexible: You don't care where an
object came from – COM interop, reflection, a dynamic language like
IronPython – you just want to manipulate it.
Type Equivalence Support
Type Equivalence Support (or "Type
Embedding") allows you to avoid a major pitfall of writing clients
against strongly-type interop assemblies; that is, when a new version of
the strongly-typed interop assembly is released, you have to recompile
your client – even if you're not using any of the new features.
Covariance and Contravariance
This is one of those tricky
things that could take up an entire article. As a matter of fact, former
"C# Corner" author Bill Wagner did just that back in May of 2009. His
article, "Generic Covariance and Contravariance in C# 4.0" provides an
in-depth look at how C# handles type conversions and decides which ones
are allowed and which aren't.
|
![]() |
|


