Monday, June 08, 2009

C# 4.0 – the features I like most.

C# 4.0 is coming up with following new features as of its documentation on MSDN now:

  1. Dynamic lookup (You don't need to worry about type of target; Runtime figures out what exactly the operation means to the object)
  2. Runtime lookup (Operation is dispatched through reflection at runtime)
  3. Named and Optional Parameters (default values can be set to function argurments)
  4. New features in COM Interop – Compiling without PIAs, Omitting Refs, Dynamic Import
  5. Variance (Automatic assignments where it is safe in case of Generics)
  6. Covariance (The new IEnumerable and IEnumerator interfaces, now sequence of strings is also sequence of objects; very useful in Linq queries)
  7. Contravriance (Type parameters can be declared as "in" in Generics; IComparer<object> can be used where we are expecting IComparer<string>)

Though I have been using dynamic languages like python and perl, I really need to explore features of Dynamic lookup. As of developer of so many APIs, I can say that Named and Optional Parameter feature is really cool. It will provides enormous flexibility to API developers as well as API users. Last one is Compiling without PIAs. The developers who have worked on PIA can only know how useful this feature is. It gives big relief from versioning and loading large assemblies.