VB for C# Developers

The lack of C# expressions in WF 4.0 is painful for all of you C# developers out there. We know, and we won’t forget about C# support when planning for future releases. However, if you are using WF 4.0, you will need to figure out how to cope with VB for now, so here are some resources to help you do so.

VB is a powerful language and it has many language features that a C# developer would expect. It does, however, have some different keywords and operators. It also has different mindset that takes some getting used to.

A good starting point is this intro post for C# developers by Kathleen Dollard. Not all of these tips and tricks will be applicable in the workflow. There are some inherent limitations in the designer because it is an expression editor, not a statement editor, and everything entered into the box must be evaluated to an expression tree. A list of limitations will be the subject of another post.

This intro was written for VB 9.0. There are a couple of improvements for VB 10.0 that are very useful.

Line continuation characters (underscores) are no longer required, so long as your expression can unambiguously be interpreted by the compiler as a single expression. For example,

True Or


is valid but


Or False

is not.

Collection initializer syntax has also been improved, you’ll see some examples of collection initializers in the next post.

Comments (1)

  1. Papy Normand says:

    I am using VC# and VB 2008 ( Standard edition ) and 2010 ( Express ) .I found that VC# is easier to use than VB.More exactly , the express VB is really painful compared to VC#. Several options are missing, for the formatting of statements and the use of intellisense is poor compared to VC#.

    When i need 3 hours to wrote 1,000 lines of code for VC#, i need a day for VB.

    Having used COBOL , C and Pascal during 23 years, it was logical that i used VB and VC++ ( versions 4 ==> 6 ) but i dropped to VC# with my 1st Visual Studio ( 2003 Standard ).VC# was a dream, VB not a joy. I have provided many code snippets in VC# and VB ( mainly for the use of SMO and SQL Server Data Access ), VB only when the poster was prefering VB to VC#.Maybe, it is only a problem of Visual Studio, but i find VB really lengthy to write ( CType is the example of horror to use that i would want to be simplified ).

    Anyway, your article is really interesting and has succeeded to reconcile me a little with VB ( + 1 for you ) and your links are +3

    For the example about True Or False written in 2 separate lines, i suppose that you meant that the Or must in the same line that the left part of  the condition ( i have difficulties with english and i prefer to ask a confirmation )