From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Some examples of C# expressions

Some examples of C# expressions

These comments I took from the Microsoft documentation. It tells us that expressions can consist of a literal value, a method invocation, an operator and its operands, and something called a simple name. And then it explains that simple names can be the name of a variable, a type member, a method parameter, a namespace, or a type. Now, as I said earlier, an expression yields a value and we can use it in any place where a value is expected, so we tend to use variables to hold the value. Here's a string variable and an int variable, but these are also considered to be expressions. Remember, the name of a variable is an expression. Though you and I don't say that, we say I'm declared a variable here; we don't say we declare an expression. Once you have the value, the variable, then I can fill it with another expression result. So here I'm going to int32. MaxValue which is a type member. And I'm using that to determine what the maximum value is for an int 32 and storing that in the…

Contents