Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/core/docker/snippets/App/Program.cs
Original file line number Diff line number Diff line change
@@ -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));
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
using System;
using UtilityLibraries;

int row = 0;
const int EntriesPerPage = 7;

do
int entryCount = 0;

ResetConsole();

while (true)
{
if (row == 0 || row >= 25)
string? input = Console.ReadLine();

if (string.IsNullOrWhiteSpace(input))
break;

if (entryCount >= EntriesPerPage)
{
Console.WriteLine("Press any key to continue...");
Console.ReadKey(true);
ResetConsole();
entryCount = 0;
}

string result = input.StartsWithUpper() ? "Yes" : "No";

Console.WriteLine($"Input: {input}");
Console.WriteLine($"{"Begins with uppercase?",30}: {result}");
Console.WriteLine();

entryCount++;
}

string? input = Console.ReadLine();
if (string.IsNullOrWhiteSpace(input)) break;
Console.WriteLine($"Input: {input} {"Begins with uppercase? ",30}: " +
$"{(input.StartsWithUpper() ? "Yes" : "No")}{Environment.NewLine}");
row += 3;
} while (true);
return;

// Declare a ResetConsole local method
void ResetConsole()
{
if (row > 0)
{
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
Console.Clear();
Console.WriteLine($"{Environment.NewLine}Press <Enter> only to exit; otherwise, enter a string and press <Enter>:{Environment.NewLine}");
row = 3;
Console.WriteLine();
Console.WriteLine("Press <Enter> only to exit; otherwise, enter a string and press <Enter>:");
Console.WriteLine();
}
Loading