Question
Please edit the C# Code provided to solve the following problem, thank you: The program accepts arguments from the Console and changes font and background
Please edit the C# Code provided to solve the following problem, thank you:
The program accepts arguments from the Console and changes font and background colors based on them. Run this code twice with different arguments/colors. Add one more catch clause to catch all other possible exceptions Run it.
using System;
using static System.Console;
namespace Arguments
{
class Program
{
static void Main(string[] args)
{
WriteLine($"There are {args.Length} arguments.");
foreach (string arg in args)
{
WriteLine(arg);
}
if (args.Length < 3)
{
WriteLine("You must specify two colors and a cursor size, e.g.");
WriteLine("dotnet run red yellow 10");
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.");
}
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started