Archive for September, 2008

Event registration in C# 2.0

September 26, 2008

The C# 2.0 (and newer) compiler is smart enough to determine the type of delegate with which a particular event is implemented. This “delegate inference” capability enables you to omit the declaration of the requisite delegate in the code that registers an event handling method with an event.

Consider the following 1.x code that registers an event handling method with an event. This code explicitly instantiates the event handler (delegate) in order to register the associated method with the event.

thePublisher.EventName += new MyEventHandlerDelegate(EventHandlingMethodName);

The following 2.0+ code uses delegate inference to register the same method with the event. Notice the following code appears to register the event handling method directly with the event.

thePublisher.EventName += EventHandlingMethodName;

When you assign the method name directly to the event like that, the C# compiler ensures that the method signature matches the signature of the event handler upon which the event is based. The C# compiler then inserts the requisite delegate registration code (i.e., ... += new MyEventHandlerDelegate(EventHandlingMethodName);) in the output assembly.

This simplified syntax is made possible by the C# compiler, and not by any change to the fundamental ways that events are implemented in the .NET Framework. To be clear, it is not the case that events in C# 2.0 (and newer) can directly reference methods. What the compiler is doing for us is supplying the [still] requisite delegate syntax in the output assembly — as if we had explicitly instantiated the delegate.

Clipped from:


Google Releases New Browser – Chrome

September 2, 2008

Google today has officially thrown it’s knock-out swing at Microsoft with the release of the official Google Chrome browser.  This is not a knock out punch, but a definitely a knockout swign destined to be a punch over the next few months.

For an entire overview of Google Chrome and it’s advance features view this mini overview in the form of a comic:

To download now:

One thing to note, Google Chrome has following user agent which indicates it’s based on the well known webkit open source browser commonly used by Apple Safari browser.

Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/ Safari/525.13