User Input in Windows Console Application – C#


 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InputTest
{
class Program
{
static void Main(string[] args)
{
System.Console.Write("SOFTWARE TERMS OF USE\nYou can use the SoftwareSamples from Chas for free, for demonstration purposes or to help you with your coding, including for business or professional use. You do not have to give credit to Chas AT ALL, though it would be appreciated.\n");
System.Console.WriteLine("Do you accept the Terms of this software?");
String agree = System.Console.ReadLine();
if (agree == "yes")
{
System.Console.WriteLine("Terms accepted. You may use this software");
}
if (agree == "YES")
{
System.Console.WriteLine("Terms accepted. You may use this software");
}
if (agree == "Y")
{
System.Console.WriteLine("Terms accepted. You may use this software");
}
if (agree == "y")
{
System.Console.WriteLine("Terms accepted. You may use this software");
}
if (agree == "n")
{
System.Console.WriteLine("You did not accept the terms. You may not use this software.");
}
if (agree == "no")
{
System.Console.WriteLine("You did not accept the terms. You may not use this software.");
}
if (agree == "NO")
{
System.Console.WriteLine("You did not accept the terms. You may not use this software.");
}
if (agree == "N")
{
System.Console.WriteLine("You did not accept the terms. You may not use this software.");
}
}
}
}

Hi guys, here is how to use input in a Windows Console Application. In this sample, the user has to type YES, yes, Y or y to get access to the software, and if they type NO, no, N or n they will not get access to the software. There is no “software” that will be installed in this script. This is only for demonstration purposes.

This blog will start displaying SeaSurf news again. ecgsoftware.wordpress.com is just information and fact about it now!

Looks like the Polldaddy Ratings are going well. I am going to change them to a five-star rating soon so I can see exactly where I have went wrong and where I have went right.

ecgsoftware.wordpress.com is now a simple Wiki-based blog. It contains pages about ECG SeaSurf and other projects I am working on, including BeProductive, which will be an addon for SeaSurf, despite formerly being known as an upcoming productivity suite.

This blog will have news about it – however, the ECG Software Wiki Blog may sometimes have exclusive news.

Keep subscribed to ecgsoftware.wordpress.com though, because of monthly news.