.NET for Visual FoxPro Developers

Appendix A
Language Comparison Tables

The tables in this appendix provide a side-by-side comparison of Visual FoxPro, C#, and VB.NET’s features.

Operator Comparison

Table 1 is an adaptation of the table found in the .NET Help topic “Operators compared in different languages”.

Table 1. A comparison of Visual FoxPro, C#, and VB.NET operators

 

Visual
FoxPro

C#

VB.NET

Math

 

 

 

Addition

+

+

+

Subtraction

-

-

-

Multiplication

*

*

*

Division

/

/

/

Modulus

%; MOD

%

Mod

Exponentiation

^, **

n/a

^

Assignment

 

 

 

Assignment

=

=

=

Addition

+

+=

+=

Subtraction

-

-=

-=

Multiplication

*

*=

*=

Division

/

/=

/=

Integer Division

n/a

/=

\=

Concatenate

+, -, $

+=

&=

Modulus

%

%=

n/a

Left Shift

BITLSHIFT()

<<=

n/a

Right Shift

BITRSHIFT()

>>=

n/a

Bitwise-AND

BITAND()

&=

n/a

Bitwise-exclusive-OR

BITXOR()

^=

n/a

Bitwise-inclusive-OR

BITOR()

|=

n/a

Relational and equality

 

 

 

Less than

< 

< 

< 

Less than or equal to

<=

<=

<=

Greater than

> 

> 

> 

Greater than or equal to

>=

>=

>=

Equal

=

==

=

Not Equal

<>, #, !=

!=

<> 

Compare two object reference variables

COMPOBJ()

==

Is

Compare object reference type

n/a

x is Class1 (see also as and typeof)

TypeOf x Is Class1


Table 1, continued

 

Visual
FoxPro

C#

VB.NET

Relational and equality (continued)

 

 

 


Compare strings

=

==

-or- String.Equals()

=

 

 

 

 

Concatenate strings

+

+

&

Shortcircuited Boolean AND

n/a

&&

AndAlso

Shortcircuited Boolean OR

n/a

||

OrElse

Shift

 

 

 

Left Shift

n/a

<< 

n/a

Right Shift

n/a

>> 

n/a

Scope Resolution

 

 

 

Scope resolution

::

. and base

.

Postfix

 

 

 

Array Element

( ), [ ]

[ ]

( )

Function call

( )

( )

( )

Type cast

n/a

(type)

CInt, CDbl, …, CType

Member selection

.

.

.

Postfix increment

n/a

++

n/a

Postfix decrement

n/a

--

n/a

Unary

 

 

 

Indirection

n/a

* (unsafe mode only)

n/a

Address of

n/a

& (unsafe mode only; also see fixed)

AddressOf

Logical-not

!

!

Not

One’s complement

BITNOT()

~

Not

Prefix increment

n/a

++

n/a

Prefix decrement

n/a

--

n/a

Size of type

n/a

sizeof

n/a

Bitwise

 

 

 

Bitwise-AND

BITAND()

&

And

Bitwise-exclusive-OR

BITXOR

^

Xor

Bitwise-inclusive-OR

n/a

|

Or

Logical

 

 

 

Logical-AND

AND

&&

And

Logical-OR

OR

||

Or

Conditional

 

 

 

Conditional

IIF

?:

IIf Function ()

Pointer to member

 

 

 

Pointer to member

n/a

.  (Unsafe mode only)

n/a

Reference

 

 

 

Reference

n/a

n/a (use reference types)

@

 


Keyword Comparison

Table 2 is an adaptation of the table found in the .NET Help topic “Keywords compared in different languages”.

Table 2. A comparison of Visual FoxPro, C#, and VB.NET keywords

Purpose

Visual
FoxPro

C#

VB.NET

Declare a variable

[implicit declaration]; also PUBLIC, LOCAL, PRIVATE

declarators (keywords include user-defined types and built-in types)

Private, Public, Friend, Protected, Static, Shared, Dim

Declare a named constant

#DEFINE

const

readonly

Const

Create a new object

CREATEOBJECT,

NEWOBJECT

new

New

Assign a variable to an object

=, also STORE

=

=

Function/method does not return a value

Void (COM Servers only)

void

Sub

Overload a function or method (Visual Basic: overload a procedure or method)

(No language keyword required for this purpose)

(No language keyword required for this purpose)

Overloads

Refer to the current object

This, ThisForm

this

Me

Make a nonvirtual call to a virtual method of the current object

n/a

 

MyClass

Retrieve character from a string

SUBSTR()

[ ]

GetChar

Declare a compound data type (Visual Basic: Structure)

n/a

struct, class, interface

Structure <members> End Structure

Initialize an object (constructors)

Init event

Constructors, or system default type constructors

Sub New()

Terminate an object directly

Destroy event

n/a

n/a

Method called by the system just before garbage collection reclaims an object

Destroy event

destructor

Finalize

Initialize a variable where it is declared

n/a

// initialize to a value

int x = 23

// or use default constructor:

int x = new int();

Dim x As Long = 5

Dim c As New Car(FuelTypeEnum.Gas)

 

Take the address of a function

n/a

delegate

AddressOf (For class members, this operator returns a reference to a function in the form of a delegate instance)

Declare that an object can be modified asynchronously

n/a

volatile

n/a


Table 2, continued

Purpose

Visual
FoxPro

C#

VB.NET

Force explicit declaration of variables

_VFP.LanguageOptions 

n/a. (All variables must be declared prior to use)

Option Explicit

Test for an object variable that does not refer to an object

EMPTY(); ISNULL()

obj == null

obj = Nothing

Value of an object variable that does not refer to an object

n/a

null

Nothing

Test for a database null expression

ISNULL()

n/a

IsDbNull

Test whether a Variant variable has been initialized

EMPTY()

n/a

n/a

Define a default property

n/a

by using indexers

Default

 

 


.NET for Visual FoxPro Developers