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.

Change color only by providing different arguments. blue pink 30 instead of red yellow 10, etc. (Run this code twice with different arguments/color)

Add one more catch clause to catch all other possible exceptions.

(Exception is the parent of all other exceptions. You can write a clause catching it and therefore catching all other possible errors. test using for example dotnet run red yellow ten) 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!