The .Net framework version 2.0 brings many new things to developers
in all languages. This has been talked about quite a bit, but I just
wanted to refresh everybody on one of things I know I'm looking forward
to. Operator overloading. If you've done any programming in C#,
none of this is new to you. If you are strictly VB.Net, or new to
any .Net language, then read on.
Operator overloading is the act of making something happen when
somebody wants to use an operator, such as + (plus sign) to add two or
more objects together. At present, you can't do this in VB.Net in fx
1.0, 1.1. Let's look at how we accomplish adding objects together in
current release versions of VB.Net
Nothing wrong with that. Just pop in an add function and we
get the functionality that we want. Consider a slight
drawback. The API user has to know there is an Add method, which
intellisense pretty much provides to the user, so its really not even a
drawback. Let’s implement the above code:
What operator overloading allows us to do is not have the Add
method, but include an operator that performs the same actions.
In this case, it will be + (plus sign)
All in all, in my opinion, easier to write, easier to read, easier to understand.
Posted
Mon, Apr 11 2005 8:00 PM
by
Raymond Lewallen