Introduction
Language is the program developers walking the hands of the sword, the Master of the Gate faction in the Forum, blog in order to quarrel with the door from the home of the beautiful scenery of the world, although how many of the novice has just stepped into the river to provide the thinking of the material, but also puzzled the fledgling forward direction.
This article does not want to dispute the gate faction, aims to discern the true meaning of technology, this is. NET Platform development tool: C # language, and from its change in the process of. NET technology development.
In the next installment, we'll take a look at the future of. NET, in particular, the new things of. NET 4.0.
. NET, the future of weapons
In any case,. NET 4.0 is already at the opening of the New Year's door, with a high-profile gesture greeted a applause. The vast number of technology enthusiasts will not wait too long, can feel the development of C # another change. With the release of. NET 4.0 in 2009, our focus on C # 4.0 will also be increasing. Overall, the C # 4.0 plays are focused on the following areas:
Dynamic programming
Parallel computing
Late binding
Covariance and Contravariance
Cut the crap, and then we'll all enjoy the language features in C # 4.0.
Dynamic programming
As we all know, C # is a statically strongly typed language. In many cases, the provision of "dynamic" behavior is a frequent occurrence, such as through reflection at run time. NET types, invoking dynamic language objects, accessing COM objects, and so on, cannot be obtained by static types. As a result, the New keyword dynamic introduced by C # 4.0 also introduces the ability to improve the interaction between static types and dynamic objects, which is dynamic lookup, for example:
// Release : code06, 2009/05/07
// Author : Anytao, http://www.anytao.com
public static void Main()
{
dynamic d = GetDynamicObject();
d.MyMethod(22); // 方法调用
d.A = d.B; // 属性赋值
d[“one”] = d[“two”]; // 索引器赋值
int i = d + 100; // 运算符调用
string s = d(1,2); // 委托调用
}
Just as an object can represent any type, dynamic enables the type decision to be made at run time, and method invocation, property access, and delegate invocation can be dynamically assigned. At the same time, dynamic characteristics are also embodied in the construction of a dynamic object, in C # 4.0 to implement the type of IDynamicObject interface, you can fully define the meaning of dynamic operations, by using the C # compiler as a run-time component to complete the operation delayed by the static compiler, for example:
dynamic d = new Foo();
string s;
d.MyMethod(s, 3, null);
In the execution process, C # 's Run-time Binder is based on run-time information, gets the actual type foo of D through reflection, and then performs method lookup and overload resolution on the Foo type, and executes the call, which is the secret behind the dynamic call: the DLR. MyMethod In. NET 4.0, an important underlying component, the DLR (Dynamic Language Runtime, dynamically language runtime), is introduced, in addition to the underlying support for dynamic lookups, the DLR also serves as an infrastructure for similar ironruby, IronPython such dynamic languages provide a unified interoperability mechanism. In summary, dynamic programming will make a huge difference in C # in the following areas:
Office programming interacts with other COM.
Dynamic language support, consuming IronRuby Dynamic language types in C # is not difficult, and experiencing dynamic language features is around the corner.