mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2025-12-06 05:32:03 +01:00
33 lines
673 B
C#
33 lines
673 B
C#
|
|
WriteLine($"There are {args.Length} arguments.");
|
|||
|
|
|
|||
|
|
foreach (string arg in args)
|
|||
|
|
{
|
|||
|
|
WriteLine(arg);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (args.Length < 3)
|
|||
|
|
{
|
|||
|
|
WriteLine("You must specify two colors and cursor size, e.g.");
|
|||
|
|
WriteLine("dotnet run red yellow 50");
|
|||
|
|
return; // stop running
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ForegroundColor = (ConsoleColor)Enum.Parse(
|
|||
|
|
enumType: typeof(ConsoleColor),
|
|||
|
|
value: args[0],
|
|||
|
|
ignoreCase: true);
|
|||
|
|
|
|||
|
|
BackgroundColor = (ConsoleColor)Enum.Parse(
|
|||
|
|
enumType: typeof(ConsoleColor),
|
|||
|
|
value: args[1],
|
|||
|
|
ignoreCase: true);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
CursorSize = int.Parse(args[2]);
|
|||
|
|
}
|
|||
|
|
catch (PlatformNotSupportedException)
|
|||
|
|
{
|
|||
|
|
WriteLine("The current platform does not support changing the size of the cursor.");
|
|||
|
|
}
|