|
Purpose |
VB.NET |
C# |
|
Declare a variable |
Private, Public, Friend, Protected, Static1, Shared, Dim |
declarators (keywords include user-defined types and built-in types) |
|
Declare a named constant |
Const |
const |
|
Create a new object |
New, CreateObject() |
new |
|
Function/method does not return a value |
Sub |
void |
|
Overload a function or method (Visual Basic: overload a procedure or method) |
Overloads |
(No language keyword required for this purpose) |
|
Refer to the current object |
Me |
this |
|
Make a nonvirtual call to a virtual method of the current object |
MyClass |
n/a |
|
Retrieve character from a string |
GetChar Function |
[] |
|
Declare a compound data type (Visual Basic: Structure) |
Structure <members> End Structure |
struct, class, interface |
|
Initialize an object (constructors) |
Sub New() |
Constructors, or system default type constructors |
|
Terminate an object directly |
n/a |
n/a |
|
Method called by the system just before garbage collection reclaims an object7 |
Finalize |
destructor |
|
Initialize a variable where it is declared |
Dim x As Long = 5
Dim c As New _
Car(FuelTypeEnum.Gas) |
// initialize to a value:
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 asynchronously |
n/a |
volatile |
|
Force explicit declaration of variables |
Option Explicit |
n/a. (All variables must be declared prior to use) |
|
Test for an object variable that does not refer to an object |
obj = Nothing |
obj == null |
|
Value of an object variable that does not refer to an object |
Nothing |
null |
|
Test for a database null expression |
IsDbNull |
n/a |
|
Test whether a Variant variable has been initialized |
n/a |
n/a |
|
Define a default property |
Default |
by using indexers |
|
Refer to a base class |
MyBase |
base |
|
Declare an interface |
Interface |
interface |
|
Specify an interface to be implemented |
Implements (statement) |
class C1 : I1 |
|
Declare a class |
Class <implementation> |
class |
|
Specify that a class can only be inherited. An instance of the class cannot be created. |
MustInherit |
abstract |
|
Specify that a class cannot be inherited |
NotInheritable |
sealed |
|
Declare an enumerated type |
Enum <members> End Enum |
enum |
|
Declare a class constant |
Const |
const (Applied to a field declaration) |
|
Derive a class from a base class |
Inherits C2 |
class C1 : C2 |
|
Override a method |
Overrides |
override |
|
Declare a method that must be implemented in a deriving class |
MustOverride |
abstract |
|
Declare a method that can't be overridden |
NotOverridable (Methods are not overridable by default.) |
sealed |
|
Declare a virtual method, property (Visual Basic), or property accessor (C#, C++) |
Overridable |
virtual |
|
Hide a base class member in a derived class |
Shadowing |
n/a |
|
Declare a typesafe reference to a class method |
Delegate |
|