Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am currently working in a console application, but got stuck in a problem:
-I want to develop a "ping-like" function. So the command would be like "ping (url)".
-The problem is, I have a "if" to administrate user input, and I don't know how to check if what the user has inputted has been "ping" + some URL, and then get the URL to ping it.

Thanks in advance, and sorry for my bad English...

What I have tried:

I'm pretty new to C#, so I don't know if there is a specific way for achieve this.
Posted
Updated 7-Jun-16 6:13am
Comments
CHill60 7-Jun-16 10:23am    
It's not that clear what you are trying to do. Use the Improve question link to show the code where you expect this to happen.
Dave Kreskowiak 7-Jun-16 10:28am    
It's not clear at all what you're doing or what the problem is.

Are you talking about parsing command line arguments? Google for "C# command line argument parsing".

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jun-16 12:19pm    
5ed, and not to counter-voted the non-motivated and inadequate vote of 1, so typical these days, but just because the idea is correct.
Please see my own alternative suggested in Solution 2.
—SA
Mehdi Gholam 7-Jun-16 12:27pm    
Thanks Sergey!
I can suggest my own command-line parsing utility which is especially easy to use, because of the declarative nature of the setting of the parsing rules: Enumeration-based Command Line Utility.

Besides, from this article, you can learn how to deal with command line, enumerations, other technical aspects and develop you own design for your code.

Another good utility published on CodeProject is referenced in my article.

—SA
 
Share this answer
 
Comments
Mehdi Gholam 7-Jun-16 12:27pm    
5'ed
Sergey Alexandrovich Kryukov 7-Jun-16 12:55pm    
Thank you, Mehdi.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900