Thursday, February 03, 2005

OMG

I was just reading a blog entry from Geoff Appleby which
contained a link to the new/changed language features in VB.NET. Now as a C#
man, I have kept fairly up to date with all the new features for C#, but I
thought why not see what is coming for VB.NET.


Anyway, while looking at some of the changes, I stumbled across this, which
basically allows a developer to explicitly define the lower bounds of an array
as 0.


Below is an example:

Public Sub declarelowerbounds()

Dim monthtotal(0 To 11) As Double
Dim cell(0 To 39, 0 To 19) As Integer
MsgBox("Total number of elements:" _
& vbCrLf & "monthtotal (0 To 11) length " & CStr(monthtotal.Length) _
& vbCrLf & "cell (0 To 39, 0 To 19) length " & CStr(cell.Length))
End Sub

Underneath this example was a little note:


"The lower bound must always be 0, but your code can be more readable
when you explicitly declare it. Specifying both bounds also reminds the reader
that the lower bound is 0."


After picking myself up off the ground, I actually read the whole article,
and it does actually state that this feature is to improve code readability.


I can only imagine that this has been added to VB.Net in order to appease the
masses, I just wonder how long until people start to complain about not being
able to specify a non-zero lower bound..


Disclaimer: Although most of my development is done in C#,
I still do have a few side projects that use VB.Net.

No comments: