Reading and Writing to a console
In this we will discuss:-
1.Reading from the console:-Way to read input from console Use the ReadLine() method to read input from the console. It comes under console class.If the standard input device is keyboard,the readline method block until the user presses the enter key
2. Writing to a console:- To print a message to the console,we use the writeline() method of console class.The class represents the standard output and error streams for console application.
3. Concatenation:- It is the operation of joining character strings end to end.You concatenate strings by using the + operator. For example,the concatenation of "hello" and "world" is "helloworld".
Reading and Writing to console:-
using System;
class Program
{
static void main()
{
Console.WriteLine("Please enter your name");
string UserName = Console.ReadLine();
Console.WriteLine("Hello " + UserName);
}
}
Comments
Post a Comment