Understanding expressions in C#

I might be writing about pretty obvious stuff today, but for me it always is helpful to write down what I want to remember.

I think it is time to get familiar with some expressions in C#. If you remember that C# is just a language, then you might find it helpful to think of nouns and verbs and grammar. That’s what makes a language.

Let’s have a look at some things:

Statements are complete instructions in C# and are made of expressions.

(In our example of looking at C# as a language a statement would be a sentence.)

A few different statements are:

declaration statement: (int x)

expression statement: ( someValue = 3*x/100; )

selection (decision) statement: (if…)

Expressions are made of operators and operands.

(Expressions would be the elements a sentence exists of.)

Operands are controls, variables, literal strings, objects, etc.

(Operands would be the nouns in our language.)

Operators act on the operands.

(Operators would be the verbs.)

The most common operators are:

. (object member access)

+ (concatenating strings, math operator addition)

(math operator subtraction)

* (math operator multiplication)’

/ (math operator division)

= (value assignment)

== (evaluation of equality)

() (method invocation)

>(more than)

< (less than)

&& ( conditional AND operator)

|| (conditional OR operator)

() (method invocation)


To be continued…

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: