Home > Articles > Web Development > ASP.NET

  • Print
  • + Share This
This chapter is from the book

Operators

Operators are symbols that are used to perform some action. For instance, the = operator can be used to assign a value to something:

strName = "Hello"

You should be already familiar with many of the operators because you use them in everyday life. Table 3.3 lists all of VB.NET's operators, in order of precedence.

Table 3.3 VB.NET Operators, in Order of Precedence

Function

Operator

Exponentiation

^

Unary negation

+, -

Multiplication, division into (6 \ 2 = .3333)

*, \

Division by (6 / 2 = 3)

/

Modulus (6 mod 4 = 2)

Mod

Addition, subtraction

+, -

Bitwise NOT, AND, OR, and XOR

Not, And, Or, Xor

Concatenation

&, + (string)

Equal to, not equal to, less than, greater than

=, <>, <, >

Less than or equal to, greater than or equal to

<=, >=

Relational

TypeOf...Is, Is, Like

Assignment

=, ^=, *=, /=, \=, +=, -=, &=

Logical NOT, AND, OR, and XOR

AND, ANDALSO, OR, XOR, ORELSE


You can use parentheses to change the order of precedence as well. For example, 4+5*3 = 19, while (4+5)*3 = 27.

The C# operators are listed in Table 3.4.

Table 3.4 C# Operators, in Order of Precedence

Type

Operators

Primary

-(x), x.y, f(x), a[x], x++, x--, new, typeof, sizeof, checked, unchecked

Unary

+, -, !, ~, ++x, --x, (T)x

Multiplicative

*, /, %

Additive

+, -

Shift

<<, >>

Relational

<, >, <=, >=, is

Equality

==, !=

Logical AND

&

Logical XOR

^

Logical OR

|

Conditional AND

&&

Conditional OR

||

Conditional

?:

Assignment

=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=

  • + Share This
  • 🔖 Save To Your Account