Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I have been making a program that, when you enter a command to run a program, it runs the program ( it is a kind of mini OS) and i need help with getting the input by the user. Here is my code:
C#
if (/*put the method for getting the user input here and check if the user has pressed the enter key here*\) {System.Diagnostics.Procces.Start(/*put the file name here*/ );} else (/* if the user has not entered a valid command*\) {Console.WriteLine(" Enter a valid command");}
can anyone help me?
Posted

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Mar-12 22:20pm    
My 5. It could help OP during the period of his ban by Google... :-)
--SA
[no name] 22-Mar-12 22:36pm    
Now now.... someone that is not capable of typing in a user name might not have a "g" or an "o" on their keyboard. And it seems to be homework week somewhere...
[no name] 23-Mar-12 1:33am    
My 5. It's homework, not a technical query.
Member 8749241 23-Mar-12 10:25am    
this is not homework i am not even in high school or collage
I agree with Wes and others and I'm doing this only because it's quiet at work and don't have interesting reading material.

Here is your code:
C#
if(Console.ReadLine() == mydesiredValue)
{
    //Some work is done here
}
else
{
    Console.Write("Your message goes here.");
}

This stuff is learned in first chapter of many beginner's tutorials.
 
Share this answer
 
Comments
Member 8749241 23-Mar-12 10:24am    
than you so much! this i a great help. i dint know this because my book i got is on Windows forms. Thanks!!!
hi hello bye
 
Share this answer
 

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