Read value from command line and check its value - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Read value from command line and check its value

Demo Code

using System;// www .j  ava 2 s  .co m
class Program
{
   static void Main(string[] args)
   {
      string result = "";
      while (true)
      {
         Console.WriteLine("Type a word: ");
         string input = Console.ReadLine();
         if (input == "")
         {
            break;
         }
         else
         {
            result += input + " ";
         }
      }
      Console.WriteLine("Result: {0}", result);
   }
}

Result


Related Tutorials