60 664
Assignments Done
97,7%
Successfully Done
In April 2018

Answer to Question #2549 in C# for ch azan

Question #2549
Create a console application to display different messages depending onthe command line argument value. Use Select-case statements.(similar toswitch block)
Expert's answer
using System;

namespace CommandLineArguments
{
class Program
{
& static void Main(string[] args)
& {
// The first element of the array is the name of the program,
// so we'll ignore it (it isn't a parameter)
for (int i = 0; i < args.Length; i++)
{
// Looking for some special parameters
switch (args[i])
{
& case "-h":
Console.WriteLine("The help parameter was detected!");
break;
& case "a":
Console.WriteLine("The parameter 'a' was detected!");
break;
& case "b":
Console.WriteLine("The parameter 'b' was detected!");
break;
& case "c":
Console.WriteLine("The parameter 'c' was detected!");
break;
& case "SomeParameter":
Console.WriteLine("'SomeParameter was detected!");
break;

// And so on...

& default:
Console.WriteLine("The unknown parameter was detected!");
break;
}
}
& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions