Colored Console
The following is one possible solution to this challenge.
This one involves multiple projects with their own configuration, so downloading the solutions might be valuable.
Main/Program.cs
using Helpers;
string? name = ColoredConsole.Prompt("What is your name?");
ColoredConsole.WriteLine("Hello " + name, ConsoleColor.Green);
Main/Main.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Helpers\Helpers.csproj" />
</ItemGroup>
</Project>
Helpers/ColoredConsole.cs
namespace Helpers;
public static class ColoredConsole
{
public static string? Prompt(string question)
{
Console.Write(question + " ");
Console.ForegroundColor = ConsoleColor.Cyan;
return Console.ReadLine();
}
public static void Write(string? text, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.Write(text);
}
public static void WriteLine(string? text, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.WriteLine(text);
}
}
Helpers/Helpers.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>