Comparison of keywords in different languages

zhaozj2021-02-16  46

Visual Studio

Comparison of keywords in different languages

This topic lists the general programming tasks that can be outlined with a language keyword. For more information on tasks that require code samples, see Using Code Examples Compare the programming concepts in different languages.

Destination Visual BasicVisual J # C C # new JScriptvisual FoxPro declared variable

Private, Public, Friend, Protected, Static1, Shared, DIM

Public, Private, Protected Static, Final, Volatile, Transient

Declare

(Concept, not a keyword) declare (keywords include user-defined types and built-in types)

VAR

[Implicit statement]; or public, local, private declares that the named constant

Const

Final

Const

Const

Readonly

Const

New #define creates a new object

New

New

New

New

New

N / a

CreateObject

() n / a

CoCreateInstance ()

(For COM object) New activityXObject () createObject; newobject assigns an object to the object variable

=

===

=

=; Or the Store function / method does not return value

Sub

2void

Void

Void

Voidvoid (for COM Server) overload function or method (Visual Basic: overloaded process or method)

OVERLOADS

NEW (no language keyword when this purpose) (no language keyword is required) (no language keyword is required) (no language keyword when this purpose is reached) (no language keyword is required) ( Do not need any language key when this purpose is reached, reference the current object

ME

3THIS

THIS

THIS

THIS

This; thisform is non-virtual call to the virtual method of the current object

Myclass

N / AMYCLASS: FUNC1 (), where MyClass is a C class that contains FUNC1 member functions. N / A / A / A Retrieves characters from strings

GetChar function

NEW "* (p 10) or P [10], where P is char * [] STR [10], the STR here is a string,

Charat

,

Substring

,

Substr

4SUBSTR () Statement Composite Data Type (Visual Basic: Structure)

Structure

End structure

Class, Interface

Class

,

Struct

,

union

__interface

Struct

,

Class

,

Interface

Class

,

Interface

NEW N / A initialization object (constructor)

Sub new ()

5 constructor (concept, not keyword)

Constructor

(Concept, not a keyword) Constructor or system default type constructor

Constructor

(Concept, Not Keyword) 6Init Event Direct Termination Object N / A ~ ClassNamen / AN / A Tight Method Call in the system before the garbage collection recycling object 7

Finalize

New (Class_Terminate in Visual Basic 6.0) Finally Destructor N / ATESTROY Event Initialize DIM at declaration variables

X as long = 5 DIM C AS New Car (FuElTyPeenum.gas) INT X = 5; // Or initialize with constructor C C (10); int x = 5; // initialize the value: int x = 123; // or use the default constructor: int x = new int ();

VAR

X = 5

VAR

Y: car = new car () N / A Gets the address of the function

Addressof

(For class members, this operator returns a reference to the function in the form of the entrusted instance) DELEGATE, MULTICAST, / ** @Delgate * /

__delegate

Delegate

Use the function name N / A callback N / A without parentheses to pass the address of a function to another callback modulator. For example, see

Use a callback function

. Callback; Callback (IDL property) N / an / an / a declaration object can be modified asynchronously N / AVOLATILE

Volatile

Volatile

N / A / a forced explicit declaration variables

Option expedition

Not available. All variables must be declared before use. Not available. All variables must be declared before use. Not available. (All variables must first declare to use) Quick mode (open by default) _VFP.LanguageOptions New test Do not reference object variables

Obj = Nothing

POBJ == nullpobj == nullobj == nullobj == undefined obj == NulleMpty (); isnull () does not reference the value of object variables

Nothing

nulln / a

NULL

Null undefinedn / A test database empty expression

ISDBNULL

Affected

System.Data.sqltypes

Support N / A / AX == Nullisnull () Test Variant variable is initialized N / A / A / A / AX == undefinedempty () Define the default properties

DEFAULT

New "" N / A

By using an indexer

N / A / a

Object-oriented programming

Destination Visual Basicvisual J # C C # New JScriptvisual FoxPro reference base class

Mybase

New Super

__super

Base

Super

New baseclass attribute; ParentClass property; DodeFault () declaration interface

Interface

New Interface

__interface

Interface

Interface

New define class Specifies the interface to be implemented

IMPLEMENTS

(Statement) IMPLEMENTS (clause in class declaration) (only from the interface) Class C1: Public I1Class C1: I1

IMPLEMENTS

New imports new declaration

Class

NEW Class

Class

Class

Class

New define class myclass as Specifies a class that can only be inherited. An instance of this class cannot be created. Mustinherit

New Abstract

__ABSTRACT

8 (only in C hosted expansion)

Abstract

Abstract

NEW N / A specifies a class that cannot be inherited.

Notinheritable

New final

__sealed

(Only in C managed expansion)

SeaD

Final

NEW N / A declares an enumeration type

ENUM

END ENUM

N / a

ENUM

ENUM

ENUM

NEW N / A declares a class constant

Const

Static final (applied to field declaration)

Const

Const

(Application to field declaration)

Const

New #define derives a class from the base class

Inherits C2

New class c1 extends C2Class C1: Public Base (no language keyword to achieve this) Class C1: C2

Class C1 Extends C2

New define class myclass as parentclass rewriting method

OVERRIDES

NEW (no language keyword when this purpose) (no language key is required)

Override

(Do not need any language key when this purpose is required) (no language keyword is required) declares that a method that must be implemented in derived classes

Mustoverride

New Abstract places = 0 in the end of the declaration (pure virtual method)

Abstract

Abstract

New (no language key when this purpose is required) declares a way to rewrite

NOTOVERRIDABLE

NEW (By default, the method cannot be rewritten.) Final

__sealed

(Only in C managed expansion)

SeaD

Final

NEW N / A declares a virtual method, a Visual Basic or attribute accessor (C #, C )

OVERRIDABLE

(By default, the method is virtual)

Virtual

Virtual

(By default, the method is virtual) N / A hidden base class members in the derived class

Shadowing

N / A / A / A

New Modifier

N / A declares a reference for a type of method for class methods

Delegate

New delegate, multicast, / ** @Delgate * /

__delegate

(Only in C managed expansion)

Delegate

Use a function name without parentheses N / A specified variables to include an object to handle its event

Withevents

N / an / a (written code - no specific keyword) (Writing code - no specific keyword) EventHandler () New Specifies events to call the event procedure for it

Handles

New (event procedure can still be associated with a WitHevents variable with a named mode.) N / an / an / AN / A Distribution value of the object expression in one time to access multiple members

With objexpr <.member> <.member> end with

N / A / A / A

WITH9WITH ... ENDWITH

Abnormal processing

Destination Visual BasicVisual J # C C # New JScriptvisual FoxPro Structured Exception Processing

Try

New

Catch

Finally

END TRY

Try, catch, finaryly, throw

__TRY, __EXCEPT

,

__finally

Try, catch, finally

,

Throw

Try, catch, finally

,

Throw

OneRror (), ComreturNError (), Error (); Message (), Aerror () C exception handling N / AN / A

Try, catch, throw

N / A / A / A

Decision structure

Destination Visual Basicvisual J # C C # New JScriptvisual FoxPro Decision Structure (Selection)

Select Case ..., Case, Case Else, End Select

Switch, Case, Break, Default

Switch, Case, Default

,

goto

,

Break

Switch

, Case, DEFAULT, GOTO, BREAK

Switch, Case

,

Break

Case decision structure (if ... then)

If ... Then, Elseif ... Then, Else, End IF

IF, ELSE

IF, ELSE

IF, ELSE

IF, ELSE

IF ... ENDIF loop structure (conditional)

While, Do [While, Until] ..., loop [while, unsil]

Do, While, Continue

Do, while

,

Continue

DO

,

While

,

Continue

Do, while

,

Break, Continue

Do, while (clause) loop structure (iteration)

For ..., [exit for,] next

For Each ..., [exit for,] next

For, Break

for

for

,

Foreach

FOR (x = 0; x <10; x ) {...}

For (prop in obj) {print (obj [prop]);}

For (clause), for ... Endfor, Continue, Next

Array

Destination Visual BasicVisual J # C C # New JScriptvisual FoxPro declares an array

DIM A () As long

int [] x = new int [5];

INT X [5];

int [] x = new int [5];

Var x: int []

,

Var arr = array ()

Dimension, Declare initializes an array

DIM A () as long = {3, 4, 5}

Int [] x = {1, 2, 3, 4, 5};

INT x [5] = {1, 2, 3, 4, 5};

Int [] x = new int [5] {1, 2, 3, 4, 5};

Var x: int [] = [1, 2, 3, 4, 5]

,

Var arr = new array (1, 2, 3, 4, 5)

Dimension, Declare reassigned an array

Redim

N / A / A / A

Arr.Length = Newsize

(Only for JScript arrays) 10DIMension, Declare class

Purpose Visual BasicVisual J # C C # New JScriptvisual FoxPro visible outside the project or program

Public

public

public

public

public

NEW PUBLIC is not visible in the assembly (C # / Visual Basic) or package (Visual J #, JScript)

Friend

(Omitted the scope of keywords will specify "package range")

Private

Internal

Internal

New N / A is only visible in the project (for nested classes, visible in the included ")

Private

Private

Private

Private

Private

New Hidden

Member range

Destination Visual BasicVisual J # C C # New JScriptvisual FoxPro Accessible access to Class and Projects (Visual J # / JScript / C / Visual Basic) or Module (Visual Basic)

Public

public

public

public

public

NEW PUBLIC is accessible outside the class, but injects within the project (C #, Visual Basic, C ) or package (Visual J #, JScript)

Friend

(Omitted the scope of keyword will specify "package range") Public private:

Internal

Internal

New N / A is only available within the class (Visual J # / JScript / C / Visual Basic) or module (Visual Basic)

Private

Private

Private

Private

Private

New Hidden can only be accessed by current class and derived class

Protected

New protected

protected

protected

protected

New protected specifies a function or another class to access the private member N / A / A of the declaration class

Friend

(Not allowed in C hosted extensions) N / an / APA is protected in the program set, which is private n / an / APROTECTED Private: (only for c hosted exclusive) n / AN / A / A

Miscellaneous survival

Purpose Visual BasicVisual J # C C # New JScriptvisual FoxPro retention process local variable

Static

11static

Static

N / A / APRIVATE shared by all instances of a class

Shared

New static

Static

Static

Static

New N / A

Miscellaneous

Destination Visual BasicVisual J # C C # New JScriptvisual FoxPro Note Code

'

REM

// / ** * / / * * /

//, / * * / for multi-line comments

//, / * * / for multi-line comments

// Used for XML comments

//, / * * / for multi-line comments

*; &&case sensitive? No Yes Whether to call the Windows API

Declare

Call N / A using J / Direct or platform

Use platform calls

N / adeclare - DLL declaration and an event

Event

,

Raiseevent

Use a java.awt.event class or / ** @Event * / N / a

Event

N / A / A thread primary

Synclock

SYNCHRONIZED

LOCK

N / A / A go to

Goto

N / a

goto

goto

N / A / a

1. STATIC can be used by itself to declare the variable (for example, Static X as long) is in the process.

2. In Visual Basic, the process using the SUB keyword declaration cannot return a value. If a process needs to return a value, you must declare it using the function keyword.

3. Do not resolve the ME when compiling, so it can be used as the return value of the attribute or method.

4. Still supporting the substr function, but it is no longer the preferred method of accessing characters in the string. Accessing a characterful way from a specific location in a string is to use parentheses. For example, if you want to access the tenth character in the string STR, use Str [10].

5. In Visual Basic, the constructor of the class derived from the .NET Framework system.Object is always named New.

6. The constructor is not allowed to be overloaded in JScript.

7. Typically, the code release in this method cannot be automatically released by the garbage collector.

8. In C , an abstract class contains at least one pure virtual member.

9. Note that there is no previous guide number used in Visual Basic. This feature is prone to confusion because the variable may be mistakenly considered attribute, and vice versa. It should also be noted that the WITH statement will generate low-efficiency code.

10. Do not reallocate arrays, and will not "grow". The JScript array (declared Array type) is always a sparse dynamic array. Notell arrays (declared as System.Array or Type []) is not a dynamic array.

11. In Visual Basic, the static partial variable of the non-shared class is stored in each class instance, rather than sharing a copy like in other languages. If a variable is used to declare a variable, the value of the variable remains in the value when the variable is lost and re-obtained.

See

Equivalent language | Using code examples Compare programming concepts in different languages ​​| Comparison of operators in different languages ​​| Comparison of data types in different languages ​​| Comparison of controls and programmable objects in different languages ​​and libraries

Send Microsoft Feedback on this topic

Microsoft Corporation. all rights reserved.

转载请注明原文地址:https://www.9cbs.com/read-21199.html

New Post(0)