Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

define EFFECTIVE PARTICIPATION

Answered: 1 week ago