A block of statements in C# is a series of individual statements enclosed by a set of curly braces ({, }). You can typically include a block of statements wherever a single statement is expected.
1 2 3 4 5 6 7 8 9 10 11 | // Single statement follows ifif (<span class="skimlinks-unlinked">DateTime.Now.DayOfWeek</span> == DayOfWeek.Monday) Console.WriteLine("Getting to work");// Block of statements follows ifif (<span class="skimlinks-unlinked">DateTime.Now.DayOfWeek</span> == DayOfWeek.Saturday){ Console.WriteLine("Making pancakes"); Console.WriteLine("Washing my socks"); Console.WriteLine("Mowing the lawn");} |
Although far less common, you can also include a block of statements to arbitrarily group a set of statements within a longer sequence of statements.
1 2 3 4 5 6 7 8 | Console.WriteLine("Reading Edith Wharton");{ Console.WriteLine("Eating lunch"); Console.WriteLine("Washing my hands");}Console.WriteLine("Studying Byzantium"); |

