Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight - Is there a performance difference between C# and VB.net Event Handlers?

Being new to both .NET and Silverlight, I have noticed that many of the tutorials for Silverlight (Tim Heuers Blog, Silverlight TV etc) are in C#. I know that the general difference between VB and C# is usually preference.

However one of the major differences I had noticed was the way C# and VB.NET handle events. Is this just a syntactical difference, or is one or the other optimized to handle events better? For example, they both get compiled down to the same Intermediate Language, but is the code that is generated identical? Seeing as Silverlight relies on this heavily, I thought it might be worth consideration.

Considering the expertise on this forum, I was wondering if anyone has done research into this, or performance testing.

like image 711
ginman Avatar asked Oct 10 '22 15:10

ginman


2 Answers

The code that gets generated may not be identical down to the instruction, but the overall effect is the same. You should not see a performance difference in that area.

VB.NET has two syntaxes for events - AddHandler, which is the same as C#'s +=, and Handles, which is just syntactic sugar for AddHandler in a constructor.

like image 133
vcsjones Avatar answered Oct 14 '22 04:10

vcsjones


They both get compiled to IL (or in this case Silverlight bytecode) and should perform exactly the same. Any differences should be just syntactical.

like image 35
Robert Beaubien Avatar answered Oct 14 '22 03:10

Robert Beaubien