concept statement in category c#

appears as: statement, statements, statement, statements, A statement
C# in Depth, Fourth Edition

This is an excerpt from Manning's book C# in Depth, Fourth Edition.

So far, this isn’t terribly exciting. You could change the method to create a List<int>, replace each yield return statement with a call to Add(), and then return the list at the end of the method. The loop output would be exactly the same, but it wouldn’t execute in the same way at all. The huge difference is that iterators are executed lazily.

C# 8 introduces switch expressions as an alternative to switch statements. This uses somewhat different syntax from switch statements, so it’s worth comparing the two. In chapter 12, when I introduced pattern matching, you looked at an example of a switch statement to compute the perimeter of different shapes. Here’s the code used in chapter 12:

Functional Programming in C#: How to write better C# code

This is an excerpt from Manning's book Functional Programming in C#: How to write better C# code.

The using static on the first line enables you to invoke the Using function as a sort of global replacement for the using statement. Notice that unlike the using statement, calling the Using function is an expression.[11] This has a couple of benefits:

11Here’s a quick refresher on the difference: expressions return a value; statements don’t.

Statements are instructions to the program, such as assignments, conditionals (if/else), loops, and so on.

Declarations (of classes, methods, fields, and so on) are often considered statements, but for the purpose of this discussion are best thought of as a category in their own right. Whether you prefer statements or expressions, declarations are equally necessary, so they’re best left out of the “statements vs. expressions” argument.

Listing 10.14. Populating the list of transactions on the statement
DSLs in Boo: Domain-Specific Languages in .NET

This is an excerpt from Manning's book DSLs in Boo: Domain-Specific Languages in .NET.

The problem with that approach for natural language processing is that you hit its limits quickly. It works only when the statements follow a rigid format, so although it may look like natural language, it is, in fact, nothing of the sort. If you want to make the language more intelligent, you have to accept the additional complexity of building a more full-featured language.

When booish sees a colon at the end of a line, it knows that the statement isn’t complete. It will then prompt you with an ellipsis (...) instead of the regular prompt (>>>) until you enter an empty line. Booish will then execute the code. If this same code were entered into a file for later execution, it would look like this:

A.4.3. For statement

A for statement has the following general form:

for <Variable> in <RangeOrSequence>:
<StatementBlock>
Boo’s for statement versus C#’s for statement

Unlike C-based languages, Boo’s for statement isn’t meant to iterate over a range of integers. Boo’s for statement is similar to C#’s foreach statement. You can mimic the C#’s for statement behavior using this:

Real-World Functional Programming with Examples in F# and C#

This is an excerpt from Manning's book Real-World Functional Programming with Examples in F# and C#.

This definition comes from a FAQ of an academic mailing list about functional languages, so it may sound a bit abstract. Believe us, the meaning will soon become clear. The “evaluation of expressions” in the first sentence represents the functional approach, compared with the “execution of commands” style of imperative code. Commands in imperative languages are called statements, so we’ll use this terminology instead. Let’s take a look at these two options in detail:

  • Execution of statements— The program is expressed as a sequence of commands, which are also called statements. Commands specify how to achieve the end result by creating objects and manipulating them. When using this approach, we typically work with objects that can be changed, and the code describes what modifications we need to perform in order to achieve the desired result. For example, we start by making a cup of black coffee. The object can be modified, so we can change it by adding two sugars to get the desired result.
  • 2.2.4. Using expressions instead of statements

    In imperative languages, an expression is simply a piece of code that can be evaluated and that yields a result. So a method call or any use of a Boolean or integer operator is an expression. A statement is a piece of code that affects the state of the program and doesn’t have any result. A call to a method that doesn’t return any value is a statement, because it affects the state of the program, depending on whatever the method does. An assignment also changes the state (by changing a value of a variable), but in the simplest version, it doesn’t return any value.