Microsoft (R) Build Engine version 17.8.0+b89cb5fde for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
StringLibrary -> C:\Projects\ClassLibraryProjects\StringLibrary\bin\Debug\net9.0\StringLibrary.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.78
using System;
using UtilityLibraries;
classProgram
{
staticvoidMain(string[] args)
{
int row = 0;
do
{
if (row == 0 || row >= 25)
ResetConsole();
string? input = Console.ReadLine();
if (string.IsNullOrEmpty(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 methodvoidResetConsole()
{
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;
}
}
}
文字列を入力して Enterキーを押してプログラムを試用し、終了するには Enter キーを押します。
ターミナル出力は次の例のようになります。
出力
Press <Enter> only to exit; otherwise, enter a string and press <Enter>:
A string that starts with an uppercase letter
Input: A string that starts with an uppercase letter
Begins with uppercase? : Yes
a string that starts with a lowercase letter
Input: a string that starts with a lowercase letter
Begins with uppercase? : No