WriteReadLineTasks1.htm |
ReadLine: User's Input
WriteLine: Machine Output |
Code :
// Namespace Declaration
//File location : C:\BareBone_CSharp\Source_Code\Template
using System;
//csc WriteReadLine.cs
using System.Collections.Generic;
// Program start class
class CsharpTemplate
{
// Main begins program execution.
static void Main()
{
Console.Write(" Please Press Enter Key to Exit");
Console.WriteLine();
Console.ReadLine();
}
}
|
|
Note the cursor in command window waiting at the prompt.
You need to Press enter to terminate the runtime phase. |
Now with this parameterized Static Main window will enforce the
command "Console.ReadLine", to process a string through "Enter" key
Strokes (events).
// Namespace Declaration
//File location : C:\BareBone_CSharp\Source_Code\Template
using System;
//csc WriteReadLineTasks.cs
using System.Collections.Generic;
// Program start class
class CsharpTemplate
{
// Main begins program execution.
static void Main(string[]
str1)
{
Console.Write(" U Entered {0} ", str1.Length);
Console.Write(" strings");
Console.WriteLine();
if(str1.Length != 0){
foreach (string arg in str1)
{
Console.Write(arg);
Console.Write(" ");
Console.ReadLine();
}
}
else
{
Console.ReadLine();
}
}
}
|
Runtime Views
|
Incase of a blank entry, the runtime phase pause at else statement,
and await for an event ("Enter =0"to exit the phase
Pressing other Keys won't abort the runtime phase.
|
|