|
Purpose
|
Visual Basic
|
Visual J#
|
C++
|
C#
|
JScript
|
Visual FoxPro
|
| Declare a variable | Dim Statement (Visual Basic) Public (Visual Basic) Friend (Visual Basic) Protected (Visual Basic) Private (Visual Basic) Shared (Visual Basic) Static (Visual Basic) 1 | public protected private static final volatile transient | declarators (concept, not keyword) | declarators (keywords include user-defined types and built-in types) | var | [implicit declaration] PUBLIC LOCAL PRIVATE |
| Declare a named constant | Const | final | const | const readonly | const | #DEFINE |
| Create a new instance of a class | New | new | new gcnew | new | new | NEWOBJECT( ) function |
| Create a new object | CreateObject() | new | CoCreateInstance() (for COM objects) | new | new ActiveXObject() | CREATEOBJECT( ) function |
| Assign an object to an object variable | = | = | = | = | = | = STORE |
| Function/method does not return a value | Sub 2 | void | void | void | void | Void (COM servers only) |
| Overload a function or method (Visual Basic: overload a procedure or method) | Overloads | (No language keyword required for this purpose) | (No language keyword required for this purpose) | (No language keyword required for this purpose) | (No language keyword required for this purpose) | (No language keyword required for this purpose) |
| Refer to the current object | Me 3 | this | this | this | this | this thisform |
| Make a nonvirtual call to a virtual method of the current object | MyClass | n/a | MyClass::Func1(), where MyClass is a C++ class with a member function Func1. | n/a | n/a | n/a |
| Retrieve character from a string | str(10) where str is a string string | str[10] where str is a string string | *(p + 10) or p[10] where p is a char* or wchar_t* | str[10] where str is a string string | str[10], where str is a string charAt substring substr | SUBSTR( ) |
| Declare a compound data type (structure) | Structure | class, interface | class struct union __interface | struct class interface | class, interface | n/a |
| Initialize an object (constructor) | Sub New() 5 | Constructors (concept, not keyword) | constructors (concept, not keyword) | Constructors, or system default type constructors Class Constructors | Constructor (concept, not keyword)6 | Init event |
| Terminate an object directly | n/a | n/a | ~ ClassName | n/a | n/a | n/a |
| Method called by the system just before garbage collection reclaims an object7 | Finalize (in Visual Basic 6.0, Class_Terminate) | finally | destructor | Destructors | n/a | Destroy event |
| Initialize a variable where it is declared | Dim x As Long = 5 Dim c As New Car(FuelTypeEnum.Gas) | int x = 5; // or initialize by constructor: C c(10); | int x=5; | // initialize to a value: int x = 123; // or use default constructor: int x = new int(); | var x = 5 var y : car = new car() | LOCAL x x = 5 |
| Take the address of a function | AddressOf (This operator returns a reference to a function in the form of a delegate instance) | delegate multicast /** @delgate */ | delegate | delegate | Use the name of the function without parentheses | n/a |
| Callback | Pass the address of one function to another that calls the invoker back. For an example, see How to: Pass Procedures to Another Procedure in Visual Basic. | Pass the address of one function to another that calls the invoker back. For an example, see Using Callback Functions. | CALLBACK (a standard type) callback (IDL attribute) | delegate | n/a | n/a |
| Declare that an object can be modified asynchronously | n/a | volatile | volatile | volatile | n/a | n/a |
| Force explicit declaration of variables | Option Explicit | n/a (All variables must be declared prior to use) | n/a (All variables must be declared prior to use) | n/a (All variables must be declared prior to use) | fast mode (on by default) | _VFP.LanguageOptions NEW |
| Test for an object variable that does not refer to an object | obj Is Nothing | pObj == null | pobj == NULL | obj == null | obj == undefined obj == null | VARTYPE(obj)=="0" |
| Value of an object variable that does not refer to an object | Nothing | null | nullptr | null | null undefined | .F. |
| Test for a database null expression | IsDbNull | Supported by various data types in the System.Data.SqlTypes namespace | n/a | n/a | x == null | ISNULL( ) |
| Test whether a Variant variable has been initialized | n/a | n/a | n/a | n/a | x == undefined | EMPTY( ) |
| Define a default property | Default | n/a | property | Indexers | n/a | n/a |