code_junkie

C#: What is the appropriate C# manner to read argument/parameters in Console applications?

Nov 12th, 2011
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3.  
  4. Console.WriteLine("Welcome To The Application");
  5.  
  6. Console.Write("Program> "); // Expecting something such as: /animal dog -c brown -s medium
  7. string sInput = Console.ReadLine();
  8.  
  9. // What would be an appropriate method to read 1. /thecommand then based on the command
  10. // maybe using switch, expect the arguments like -c brown -s medium or -c green -y 1999
  11. // and display them into the console?
  12.  
  13.  
  14. // if /animal is detected, display what would be:
  15. // Console.WriteLine("Animal: dog");
  16. // Console.WriteLine("Color: brown");
  17. // Console.WriteLine("Size: medium");
  18.  
  19. // if /car is detected, display what would be:
  20. // Console.WriteLine("Car: civic");
  21. // Console.WriteLine("Color: green");
  22. // Console.WriteLine("Year: 1999");
  23.  
  24. }
Add Comment
Please, Sign In to add comment