mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-05 06:15:24 +00:00
Initial commit
This commit is contained in:
parent
d5bde3c775
commit
5fb8e6929b
33 changed files with 842 additions and 0 deletions
15
vscode/Chapter02/Arguments/Arguments.csproj
Normal file
15
vscode/Chapter02/Arguments/Arguments.csproj
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System.Console" Static="true" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
32
vscode/Chapter02/Arguments/Program.cs
Normal file
32
vscode/Chapter02/Arguments/Program.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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.");
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"profiles": {
|
||||
"Arguments": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "red yellow 50"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue