Control variable scope and logic using code blocks in C#
Use code blocks with more confidence, understanding how they impact the visibility and accessibility of both higher and lower-level constructs in your code.
Learning objectives
After you complete this module, you'll be able to:
Understand the impact of declaring and initializing variables inside and outside of code blocks
Remove code blocks in if statements to improve readability when there's only one line of code in the body of the code block
Describe the purpose and scoping hierarchy for namespaces, classes, and methods
Prerequisites
Experience creating simple C# applications that include console I/O and access the methods of .NET classes such as String and Random
Experience using Visual Studio Code to develop, build, and run C# console applications that implement arrays, if-elseif-else statements, and foreach statements
Experience using operators to evaluate an expression or condition in C#