C# programming articles
All C# programming articles and chapters are listed on this page, starting with the introductory chapters up to the more complex and abstract topics.
The fundamentals of C#
The articles and chapters in this part focus on learning the basics of C#.
Operators are used in C# for a wide range of operations, from addition to comparing complex expressions. The articles below discuss the various operators and how they work, starting with the chapter’s introductory overview and ending with a summary.
- The arithmetic operators (+, -, /, *) in C# for performing calculations
- Arithmetic operators and the resulting data type in C#
- Arithmetic operators and special floating point values: infinity, zero, and NaN values
- The modulus operator (%) in C#: remainder of division
- Compound assignment operators in C#: combining an operator with assignment
Increment and decrement operators
- C#’s increment (++) and decrement operators (–): adding or subtracting 1
- How do the prefix and postfix increment and decrement operators work in C#?
Relational and logical operators
- Relational operators in C#: comparing for true or false
- Comparing floating point numbers with relational operators
- Using the relational operators with zeros, NaN, and infinity floating point values
- Logical operators in C#: evaluating Boolean values
- Combining logical and relational operators in C#
- What is C#’s short-circuit evaluation?
- Tip: use short-circuit evaluation in C# for preventing exceptions
- The conditional operator in C#: a concise if/else statement
Order of operations
The articles in this part aren’t written in the chapter style I’ve adopted since then, but will be replaced over time with complete chapters.
- DateTime to string: using custom date and time formatting when outputting a DateTime type
- Formatting a string with substitution parameters and escape characters
Branching in C#: the if and switch statements
- If statements: conditional branching the code flow
- If-else statements and cascaded if statements
- Nested if statements: embedding an if statement inside another if statement
- The switch statement: conveniently branch based on a list of possible values
- Working with fall through cases in the C# switch statement
- Using goto to ‘jump’ to another case in a switch statement
Looping in C#
- While loops in C#: repeatedly iterating over the same statements
- The for loop: repeating with a fixed amount of iterations
- The do-while loop: execute once, then repeat as long as the condition is true
- The foreach loop: conveniently iterate over a collection
- For loops: step-by-step and visually explained
- Nested for loops in C#: looping inside another loop
- Alternative for loops in C#: working with the optional header parts
- Using the break statement to prematurely exit a loop
- Skipping a loop iteration with the continue statement
- Controlling a loop with the modulus operator
- Using break and continue with nested loops in C#
- Enumerations in C#: easily group logically related constants together
- Assigning constant values to enumerators
- Specifying the base type of C# enumerations
C# programming tips