C# Expressions


This entry is part 2 of 4 in the series C# Primitives and Expressions

Expressions combine operators with variables and literal values. What does this mean? Variables store data, and are analogous to boxes sitting on a shelf that store things. Variables come in different flavors call types, just as boxes come in different shapes and sizes. To use variables you need to first declare them. Literal values are the characters and numbers you are familiar with, such as “hello world” and 17. In C#, many of these literals have suffixes. Literal values are fixed (unchanging). Variables, as the word implies, can be changed. Operators do things to other things. An assignment operator will give a value to a variable, or will put something in a box (to use our analogy). When you assign string literal values (like “Hello there”), double quotation marks are required to enclose the string.

Mosh’s Recommended Blogs

Mosh Hamedani, who has created several courses at Udemy.com has recommended a few good C# blogs in the Advanced C# course.

  • http://odetocode.com
  • http://weblogs.asp.net/scottgu
  • http://hanselman.com/blog/

Expressions

What is an expression in C#? Expressions provide the C# programmer a means to manipulate data that’s stored in variables. Manipulating data is what computer programming is all about. A variable initializer consists of an equal sign followed by the initializing value, and in the example below that is: equals five.

Expressions consist of types and identifiers.

Series Navigation<< C# PrimitivesC# Type Conversion >>