From 3152984c9bf8e5836066a51225957feaf9cd3814 Mon Sep 17 00:00:00 2001 From: Mischa van den Burg Date: Tue, 16 Apr 2024 19:30:00 +0200 Subject: [PATCH] Automated commit at Tue Apr 16 19:30:00 CEST 2024 --- content/C sharp.md | 2 ++ content/if statements.md | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 content/if statements.md diff --git a/content/C sharp.md b/content/C sharp.md index 3407c6a33..7e3ed543f 100644 --- a/content/C sharp.md +++ b/content/C sharp.md @@ -4,6 +4,8 @@ - [[Installing .NET on MacOS]] - [[Type casting]] - [[Verbatim string literal]] +- [[C sharp Code Style]] + - [[if statements]] ## Links: diff --git a/content/if statements.md b/content/if statements.md new file mode 100644 index 000000000..75e969cba --- /dev/null +++ b/content/if statements.md @@ -0,0 +1,13 @@ + +When implementing an `if` statement that includes a single-statement code block, Microsoft recommends that you consider these conventions: + +- Never use single-line form (for example: if (flag) Console.WriteLine(flag); +- Using braces is always accepted, and required if any block of an if/else if/.../else compound statement uses braces or if a single statement body spans multiple lines. +- Braces may be omitted only if the body of every block associated with an if/else if/.../else compound statement is placed on a single line. + + +## Links: + +[Exercise - Remove code blocks from if statements - Training | Microsoft Learn](https://learn.microsoft.com/en-us/training/modules/csharp-code-blocks/3-exercise-remove-if-statements) + +202404161912 \ No newline at end of file