- Learn C# in 7 days
- Gaurav Aroraa
- 303字
- 2021-07-08 09:51:27
Understanding statements
In C#, you can evaluate different kinds of expression that would or would not generate the results. Whenever you say something like what would happen if result >0, in that case, we are stating something. This can be a decision-making statement, result-making statement, assignment statement, or any other activity statement. On the other hand, loops are a code block that repeatedly executes a couple of statements.
In this section, we will discuss statements and loops in detail.
A statement should perform some action before returning a result. In other words, if you are writing a statement, that statement should say something. To do that, it has to execute some inbuilt or custom operations. Statements can depend upon a decision or can be a part of the result of any existing statement. The official page (https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/statements) defines statement as:
Take a look at the following code snippet, which shows different statements:
private static void StatementExample() { WriteLine("Statement example:"); int singleLineStatement; //declarative statement WriteLine("'intsingleLineStatement;' is a declarative statment."); singleLineStatement = 125; //assignment statement WriteLine("'singleLineStatement = 125;' is an assignmnet statement."); WriteLine($"{nameof(singleLineStatement)} = {singleLineStatement}"); var persons = newList<Person> {
newAuthor {Name = "Gaurav Aroraa" } }; //declarative and assignmnet statement WriteLine("'var persons = new List<Person>();' is a declarative and assignmnet statement.");
//block statement foreach (var person in persons) { WriteLine("'foreach (var person in persons){}' is a block statement."); WriteLine($"Name:{person.Name}"); } }
In the preceding code, we used three type statements: declarative, assignment, and block statements. The code produces the following result:

According to the official page (https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/statements), C# statements can be broadly divided into the following categories.
- Ceph Cookbook
- Photoshop智能手機APP UI設計之道
- 編程卓越之道(卷3):軟件工程化
- Mastering Articulate Storyline
- Getting Started with Greenplum for Big Data Analytics
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- Processing創意編程指南
- Python網絡爬蟲技術與應用
- 單片機原理及應用技術
- Mastering Leap Motion
- Mastering PowerCLI
- 計算機系統解密:從理解計算機到編寫高效代碼
- Hands-On ROS for Robotics Programming
- Tkinter GUI Programming by Example
- Mastering Magento Theme Design