DPE Web Applications 2.x

Differences between C# and VB.Net Syntax

Workflows use VB.Net syntax for expressions. 

WorkflowEditor 2.x will support C# syntax for expressions.


VB.Net

C#

Case-sensitive

no

yes

Null reference


Visual Basic
Nothing
C#
null

Equals operator

=

==

Equals Not operator

<>

!=

Comparison to null

Visual Basic
a is Nothing
C#
a == null

Character literal

"a"C

'a'

String escaping

Backslash: "\"

Quotes: double quote

Backslash: "\\" or @"\"

Quotes: "\"" or @"""" (double quote)

Access indexed elements

Round brackets ( )

Square brackets [ ]

Generic types

Visual Basic
New List(Of String)
New Dictionary(Of String, Object)
C#
new List<string>()
new Dictionary<string, object>()

Object initializers

Visual Basic
New Entry With { .Title = "Test" }
Visual Basic
New List(Of String) From { "abc", "def" }


For a typed array Int32[]

Visual Basic
{ 3,1,4 }
C#
new Entry { Title = "Test" }
C#
new List<string> { "abc", "def" }


For a typed array Int32[]

C#
{ 3,1,4 }

Short-circuiting logical operators

Visual Basic
a AndAlso b
a OrElse b

And/Or are always evaluating ALL parts of it!

C#
a && b
a || b

Non-short circuiting logical operators

Visual Basic
a And b
a Or b


Example:

Visual Basic
Not (entry Is Nothing) And entry.Title = "Test"

Will throw exception when entry is Nothing!

n/a

Anonymous function

Visual Basic
Function(a,b) a+b
C#
(a,b) => a + b

LINQ

Visual Basic
a.Select(Function(n) n+1).ToArray()
C#
a.Select(n => n+1).ToArray()

Data type names

Integer

int


Also see https://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Visual_Basic_.NET