What Anonymous Methods Might Look Like in VB.NET
VB.NET Anonymous Methods
So what might anonymous methods look like in VB.NET? Well, all .NET languages produce CIL (Common Intermediate Language) or MSIL (Microsoft Intermediate Language), which is a derivative of CIL. This means their results are identical whether the anonymous method comes from C# or VB.NET. The biggest difference between these two languages is really that C# is terse relative to VB's verbosity.
Listing 3: Anonymous VB.NET Methods
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
AddHandler Button1.Click, _
Not very pretty, is it? VB.NET uses the new keyword Operator for overloaded operators, so why not Method for anonymous methods? The anonymous method begins at the Begin Method line and ends at the End Method line.
Maybe the reason anonymous methods aren't in beta 2 is because the VB.NET team can't figure how to make them look better. Making them work should not be a problem though.
Time Will Tell Soon Enough
VS 2005 is already a great product, but there is a lot of work left to do. The latest news is that it will be released around November 7. As always, it will be interesting to see what is included, what gets left on the cutting room floor, and just how good of a guesser I am.
About the Author
Paul Kimmel is the VB Today columnist for www.codeguru.com and has written several books on object oriented programming and .NET. Check out his upcoming book UML DeMystified from McGraw-Hill/Osborne (Spring 2005) and Expert One-on-One Visual Studio 2005 from Wrox (Fall 2005). Paul is also the founder and chief architect for Software Conceptions, Inc, founded 1990. He is available to help design and build software worldwide. You may contact him for consulting opportunities or technology questions at firstname.lastname@example.org.
If you are interested in joining, sponsoring a meeting, or posting a job then checkout www.glugnet.org, the web page of the Greater Lansing area Users Group for .NET.
Page 2 of 2