Keyword Differences:
Declare a variable:
VB.NET:
Private, Public, Friend, Protected, Static1, Shared, Dim
C#:
declarators (keywords include user-defined types and built-in types)
Declare a named constant:Private, Public, Friend, Protected, Static1, Shared, Dim
C#:
declarators (keywords include user-defined types and built-in types)
VB.NET:
Const
C#:
ConstCreate a new object:
Const
C#:
ConstCreate a new object:
VB.NET:
New, CreateObject()
C#:
new
Functionmethod does not return a valueNew, CreateObject()
C#:
new
VB.NET:
Sub
C#:
void
Overload a function or method (Visual Basic overload a procedure or method):Sub
C#:
void
VB.NET:
Overloads
C#:
(No language keyword required for this purpose)
Refer to the current objectOverloads
C#:
(No language keyword required for this purpose)
VB.NET:
Me
C#:
thisMake a nonvirtual call to a virtual method of the current object:Me
C#:
VB.NET:
MyClass
C#:
na
MyClass
C#:
na
Retrieve character from a string:
VB.NET:
GetChar Function
C#:
[]
Declare a compound data type (Visual Basic Structure):GetChar Function
C#:
[]
VB.NET:
Structure members End Structure
C#:
struct, class, interface
Initialize an object (constructors):Structure members End Structure
C#:
struct, class, interface
VB.NET:
Sub New()
C#:
Constructors, or system default type constructors
Terminate an object directly:Sub New()
C#:
Constructors, or system default type constructors
VB.NET:
na
C#:
na
Method called by the system just before garbage collection reclaims an object7:na
C#:
na
VB.NET:
Finalize
C#:
destructor
Initialize a variable where it is declared:Finalize
C#:
destructor
VB.NET:
Dim x As Long = 5
Dim c As New Car(FuelTypeEnum.Gas)
initialize to a value
C#:
int x = 123;
or use default
constructor
int x = new int();
Take the address of a function
AddressOf (For class members, this operator returns a reference to a function in the form of a delegate instance) delegate
Declare that an object can be modified asynchronouslyDim x As Long = 5
Dim c As New Car(FuelTypeEnum.Gas)
initialize to a value
C#:
int x = 123;
or use default
constructor
int x = new int();
Take the address of a function
AddressOf (For class members, this operator returns a reference to a function in the form of a delegate instance) delegate
VB.NET:
na
C#:
volatile
Force explicit declaration of variables:na
C#:
volatile
VB.NET:
Option Explicit
C#:
na. (All variables must be declared prior to use)
Test for an object variable that does not refer to an object
Option Explicit
C#:
na. (All variables must be declared prior to use)
VB.NET:
obj = Nothing
C#:
obj == null
Value of an object variable that does not refer to an object
obj = Nothing
C#:
obj == null
Value of an object variable that does not refer to an object
VB.NET:
Nothing
C#
null
Test for a database null expressionNothing
C#
null
VB.NET:
IsDbNull
C#
na
Test whether a Variant variable has been initializedIsDbNull
C#
na
VB.NET:
na
C#
na
Define a default propertyna
C#
na
VB.NET:
Default
C#
by using indexers
Refer to a base classDefault
C#
by using indexers
VB.NET:
MyBase
C#
base
Declare an interfaceMyBase
C#
base
VB.NET:
Interface
C#
interface
Specify an interface to be implementedInterface
C#
interface
VB.NET:
Implements (statement)
C#
class C1I1
Declare a classImplements (statement)
C#
class C1I1
VB.NET:
Class implementation
C#
class
Specify that a class can only be inherited. An instance of the class cannot be created.Class implementation
C#
class
VB.NET:
MustInherit
C#
abstract
Specify that a class cannot be inheritedMustInherit
C#
abstract
VB.NET:
NotInheritable
C#
sealed
Declare an enumerated typeNotInheritable
C#
sealed
VB.NET:
Enum members End Enum
C#
enum
Declare a class constantEnum members End Enum
C#
enum
VB.NET:
Const
C#
const (Applied to a field declaration)
Derive a class from a base classConst
C#
const (Applied to a field declaration)
VB.NET:
Inherits C2
class C1C2
Override a methodInherits C2
class C1C2
VB.NET:
Overrides
C#
override
Declare a method that must be implemented in a deriving classOverrides
C#
override
VB.NET:
MustOverride
C#
abstract
Declare a method that can't be overriddenMustOverride
C#
abstract
VB.NET:
NotOverridable (Methods are not overridable by default.)
C#
sealed
Declare a virtual method, property (Visual Basic), or property accessor (C#, C++)NotOverridable (Methods are not overridable by default.)
C#
sealed
VB.NET:
Overridable
C#
virtual
Hide a base class member in a derived classOverridable
C#
virtual
VB.NET:
Shadowing
C#
na
Declare a typesafe reference to a class methodShadowing
C#
na
VB.NET:
Delegate
C#
delegate
Specify that a variable can contain an object whose events you wish to handleDelegate
C#
delegate
VB.NET:
WithEvents
(Write code - no specific keyword) Specify the events for which an event procedure will be called Handles (Event procedures can still be associated with a WithEvents variable by naming pattern.)
C#:
na
Evaluate an object expression once, in order to access multiple membersv
WithEvents
(Write code - no specific keyword) Specify the events for which an event procedure will be called Handles (Event procedures can still be associated with a WithEvents variable by naming pattern.)
C#:
na
VB.NET:
With objExpr
.member
End With
C#:
na
Structured exception handlingWith objExpr
.member
End With
C#:
na
VB.NET:
Try attempt
Catch
handle errors
Finally
always execute
End Try
C#:
try, catch, finally, throw
Decision structure (selection)Try attempt
Catch
handle errors
Finally
always execute
End Try
C#:
try, catch, finally, throw
VB.NET:
Select Case ..., Case, Case Else, End Select
C#:
switch, case, default, goto, break
Decision structure (if ... then)Select Case ..., Case, Case Else, End Select
C#:
switch, case, default, goto, break
VB.NET:
If ... Then, ElseIf ... Then, Else, End If
C#:
if, else
Loop structure (conditional)If ... Then, ElseIf ... Then, Else, End If
C#:
if, else
VB.NET:
While, Do [While, Until] ..., Loop [While, Until]
C#:
do, while, continue
Loop structure (iteration)While, Do [While, Until] ..., Loop [While, Until]
C#:
do, while, continue
VB.NET:
For ..., [Exit For], Next
For Each ..., [Exit For,] Next
C#:
for, foreach
Declare an arrayFor ..., [Exit For], Next
For Each ..., [Exit For,] Next
C#:
for, foreach
VB.NET:
Dim a() As Long
C#:
int[] x = new int[5];
Initialize an arrayDim a() As Long
C#:
int[] x = new int[5];
VB.NET:
Dim a() As Long = {3, 4, 5}
C#:
int[] x = new int[5] {1, 2, 3, 4, 5};
Reallocate arrayDim a() As Long = {3, 4, 5}
C#:
int[] x = new int[5] {1, 2, 3, 4, 5};
VB.NET:
Redim
C#:
na
Visible outside the project or assemblyRedim
C#:
na
VB.NET:
Public
C#:
public
Invisible outside the assembly (C#Visual Basic) or within the package (Visual J#, JScript)Public
C#:
public
VB.NET:v
Friend
C#:
internal
Visible only within the project (for nested classes, within the enclosing class)C#:
internal
VB.NET:
Private
C#:
private
Accessible outside class and project or module
VB.NET:
Public
C#:
public
Accessible outside the class, but within the projectPublic
C#:
public
VB.NET:
Friend
C#:
internal
Only accessible within class or moduleFriend
C#:
internal
VB.NET:
Private
C#:
private
Only accessible to current and derived classesPrivate
C#:
private
VB.NET:
Protected
C#:
protected
Preserve procedure's local variablesProtected
C#:
protected
VB.NET:
Static
C#:
na
Shared by all instances of a class Static
C#:
na
VB.NET:
Shared
C#:
static
Comment codeShared
C#:
static
VB.NET:
'
C#
Rem
'
C#
Rem
VB.NET:
, for multi-line comments
C#
for XML comments
Case-sensitive , for multi-line comments
C#
for XML comments
VB.NET:
No
C#:
Yes
Call Windows APINo
C#:
Yes
VB.NET:
Declare API
C#:
use Platform Invoke
Declare and raise an eventDeclare API
C#:
use Platform Invoke
VB.NET:
Event, RaiseEvent
C#:
event
Threading primitivesEvent, RaiseEvent
C#:
event
VB.NET:
SyncLock
C#
LockSyncLock
C#
VB.NET:
Go to
Goto
C#:
goto
Go to
Goto
C#:
goto