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)
1
Expert's answer
2011-05-23T11:18:57-0400
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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS