Posts Tagged ‘C# 4.0’

In Groovy ConfigSlurper is a utility class that is used for reading configuration files written in form of Groovy scripts.Let’s consider the following properties file. We will use a Groovy script to read from this properties file as shown in the snippet below: This is a very simple piece of code which makes use of [...]

Tuple in C# 4.0

Posted: November 29, 2009 in .NET, C#
Tags: ,

Tuple provides us with a way to group elements of disparate data types together.This is present in functional languages like Haskell and also dynamic languages like Python.A common example of a tuple is a pair of coordinates defining a point in two dimensional space.In Haskell a tuple storing name and age of person is defined [...]

Dynamic Reception in C#

Posted: November 22, 2009 in .NET, C#
Tags: ,

In my last couple of posts I had discussed about the new dynamic keyword introduced in C# 4.0 and the how the DLR integrates with CLR to provide the dynamic programming services.In this post I will discuss about the System.Dynamic.DynamicObject class and how we can implement dynamic receivers in C#.Dynamic Receivers allows the client code [...]

Laziness in C# 4.0 – Lazy<T>

Posted: October 4, 2009 in .NET, C#
Tags: , ,

“Lazy Instantiation” defers creation of an object till the time it is actually accessed.The process of object creation is always expensive as it involves allocation of memory on the heap.So Lazy Instantiation optimizes resources by using them when it is actually required.Till C# 3.0 we needed to some custom coding to implement “Lazy Instantiation” pattern.Now [...]

Dynamic in C# – Part3

Posted: September 19, 2009 in .NET, C#
Tags: , ,

In the last two posts we have discussed about dynamic languages and how DLR allows dynamic languages to run on CLR.In this post we will take a look into the new “dynamic” type in C# and how it works internally. Let us take a look into the following lines of code:

Dynamic in C# – The DLR (Part 2)

Posted: September 13, 2009 in .NET, C#
Tags: , ,

In my last post I have covered the basics of dynamic languages and now we will see how this dynamic languages fit into the CLR.The core purpose of CLR was to host code written in multiple programming languages.But traditionally it had support for the static languages only.Dynamic Language Runtime (DLR) was conceived as a set [...]