By now you should be comfortable with the basics of the C# programming language. Below is a summary of some of the concepts covered in this section.
Exceptions allow you to catch and handle errors rather than letting your application crash.
The goto statement transfers the program control directly to a labelled statement.
Refactoring allows you to store a block of code as a method.
A static method belongs to the class and not an instance of a class (object).
A static class can only have static members and you cannot create an instance of it.
The 'if' statement allows a choice to be made between two program statements depending upon the result of testing to see if a condition is either true or false.
The conditional statement switch, selects one of a number of possible statements for execution based on a value of an expression.
We can cast one type to another, although there is a chance that valuable information held in the variable can be lost if you wrongly cast the variable to another type which holds less information.
Boxing is the technique of changing a value type into a reference type.
Unboxing takes a reference type and converts it to a value type.
A while loop executes a statement, or a block of statements within the scope of the loop, repeatedly until a specified expression evaluates to false. A while loop executes zero or more times.
A do-while executes a statement, or a block of statements within the scope of the loop, repeatedly until a specified expression evaluates to false. A do loop executes at least once.
A constant is any value type or string that is fixed and unalterable.
An enumeration contains a related group of constants of the same type.
| Term |
Description |
| Boxing |
Technique of changing a value type into a reference type. |
| catch |
Specifies what code should be executed when an exception occurs. |
| const |
Specifies that the value of the field or the local variable cannot be modified. |
| do |
A loop that executes a block of statements repeatedly until a specified expression evaluates to false. |
| enum |
Used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. |
| finally |
Specifies the block of code that will always be executed after a try-catch code block executes. |
| goto |
Control statement that transfers the program control directly to a labeled statement. |
| if |
The conditional statement ‘if’, selects one of a number of possible statements for execution based on the value of a boolean expression. |
| static |
This modifier means that the member exists without an instance of the class. |
| switch |
The conditional statement switch, selects one of a number of possible statements for execution based on a value of an expression. |
| try |
Specifies that the enclosed block of code should be watched for exceptions to be thrown while executing. |
| Unboxing |
Technique of changing a reference type into a value type. |
| while |
A loop that executes a block of statements repeatedly until a specified expression evaluates to false. |