Operators

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 3.  Using Visual Basic.NET and C#


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 =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net