Thursday, April 22, 2010

A Few New Things In .Net 4 & C# 4

Tuple

http://msdn.microsoft.com/en-us/library/dd414846.aspx

http://msdn.microsoft.com/en-us/library/system.tuple.aspx

Basically a better option than using object[] in some scenarios (Tuple elements are typed).

Useful For

· Creating arbitrarily sized sets of individually typed elements (can be longer than 8, just tricky).

· Creating functions with multiple return values.

· Create simple structs/classes on the fly.

· Pass multiple parameters in a single one (e.g. Thread.Start(Object)).

MEF

http://msdn.microsoft.com/en-us/library/dd235164(v=VS.100).aspx

http://mef.codeplex.com/

Used to make plug-ins.

(Also note the similar preexisting alternative, MAF, in the System.Addin namespace).

DynamicObject

http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject(v=VS.100).aspx

This is the guy responsible for all of the dynamic keyword magic. You can subclass this to create your own dynamic objects (e.g. all properties on your object can dynamically be mapped to xml elements).

ExpandoObject

http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject(v=VS.100).aspx

This is the guy that you can add members to dynamically.

Named & Optional Parameters

http://www.dotnetcube.com/post/Overview-of-NET-40-features-e28093-C-40-Named-and-Optional-Parameters.aspx

Yay, C# has optional parameters now!

Parallelism

http://www.danielmoth.com/Blog/parallelising-loops-in-net-4.aspx

Getting fancy with threading syntax.

Task

http://msdn.microsoft.com/en-us/library/system.threading.tasks.task.aspx

http://www.danielmoth.com/Blog/New-And-Improved-CLR-4-Thread-Pool-Engine.aspx

http://www.danielmoth.com/Blog/Introducing-The-New-Task-Type.aspx

Super threading (thread pool enhancements).

Exception Handling Changes

http://geekswithblogs.net/sdorman/archive/2008/11/07/clr-4.0-corrupting-state-exceptions.aspx

Boring… but probably very important to know.

3 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

    ReplyDelete