Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

The differences, part 2

2009-05-04

Visual Basic 9 and C# 3.5 has much in common, and I suspect that they will differ more in the future. I have pointed out some current differences, like completion lists, object initializers, deep XML support and declarative events.

A few more VB-specific features:

Properties with parameters is an odd feature. By creating an object with parameterized properties you can give the impression that the object has different object with indexers as members. Properties with parameters can not be accessed from C#. A property with two parameters can look like this:

Public Property MyProperty(ByVal X As Integer, ByVal Y As Integer) As String
    Get
    End Get
    Set(ByVal value As String)
    End Set
End Property

The My namespace in Visual Basic is an extensible namespace with hierarchical arranged functions. It is loaded with function to manage sound, file transfers and other handy things, and you can extend it by simply creating hidden modules under the My namespace.

Optional parameters in functions is a feature that has been around in Visual Basic for a long while, that will be available in C# version 4. This shows how to only pass the sixth parameter to a function:

DoSome(, , , , , 55)

Aditionally, you can clarify by naming the argument. This example also calls the sixth parameter (called B in this example):

DoSome(B := 55)

Named arguments will also be available in C# 4, with slightly different syntax (loose the colon).

Categories: General, Visual Basic 9

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips