Sunday, November 14, 2010

Lesson 29 - Statements, Expressions, and Operators

Statements
bool IsPositive(int number)
{
if (number > 0)
{
return true;
}
else
{
return false;
}
}

Expressions

Literals and Simple Names

int i = 5;
string s = "Hello World";

Invocation Expressions

int var = 5;
DoWork(var);

y++;
y = 2 + 3;

Primary

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

Unary

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

Arithmetic — Multiplicative

*, /, %

Arithmetic — Additive

+, -

Shift

<<, >>

Relational and type testing

<, >, <=, >=, is, as

Equality

==, !=

Logical, in order of precedence

&, ^, |

Conditional, in order of precedence

&&, ||, ?:

Assignment

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

No comments:

Post a Comment