C# dynamic keyword

less than 1 minute read

.NET 4.0(vs2010) introduced the dynamic feature to support better integration of dynamic language such as Python, Ruby etc.
Example)
Without dynamic feature.

1
2
3
4
5
6
object calc = GetCalculator();
Type calcType = calc.GetType();
object res = calcType.InvokeMember("Add",
    BindingFlags.InvokeMethod, null,
    new object[] { 10, 20 });
int sum = Convert.ToInt32(res);
With dynamic feature.
1
2
dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);

You can find more information from the following URL.
http://dlr.codeplex.com/