diff --git a/docs/core/docker/snippets/App/Program.cs b/docs/core/docker/snippets/App/Program.cs index 82e9ce0b61b99..58cf2ea5e871f 100644 --- a/docs/core/docker/snippets/App/Program.cs +++ b/docs/core/docker/snippets/App/Program.cs @@ -1,9 +1,16 @@ var counter = 0; -var max = args.Length is not 0 ? Convert.ToInt32(args[0]) : -1; -while (max is -1 || counter < max) +// If a number is passed as a command-line argument, +// it will be used as the maximum counter value. +var max = args.Length > 0 && int.TryParse(args[0], out var parsedMax) + ? parsedMax + : -1; + +// Run indefinitely if no max value is provided +while (max == -1 || counter < max) { Console.WriteLine($"Counter: {++counter}"); - await Task.Delay(TimeSpan.FromMilliseconds(1_000)); + // Wait for one second between iterations + await Task.Delay(TimeSpan.FromSeconds(1)); } diff --git a/docs/csharp/tour-of-csharp/tutorials/snippets/ListCollection/list.cs b/docs/csharp/tour-of-csharp/tutorials/snippets/ListCollection/list.cs index c898bbf5fa803..21a840b450d2a 100644 --- a/docs/csharp/tour-of-csharp/tutorials/snippets/ListCollection/list.cs +++ b/docs/csharp/tour-of-csharp/tutorials/snippets/ListCollection/list.cs @@ -4,6 +4,8 @@ { Console.WriteLine($"Hello {name.ToUpper()}!"); } +// Fancy example +names.ForEach(name => Console.WriteLine("Hello {0}", name)); // // @@ -91,4 +93,4 @@ void ChallengeAnswer() Console.WriteLine(item); } // -} +} \ No newline at end of file