In the C# programming language Console.ReadLine() method are used to read the input string from console. Console.WriteLine() method are used to write the content to console.
There are two way to write any text to console using Console.WriteLine() method.
- Concatenation
- Place holder syntax - Most preferred
Example:
class Program
{
static void Main(string[] args)
{
//Writes the specified string, followed by the current line terminator, to the standard output stream
Console.WriteLine("Please enter first name : ");
//Reads the next line of characters from the standard input stream
string first_Name = Console.ReadLine();
Console.WriteLine("Please enter last name : ");
string last_Name = Console.ReadLine();
//print full name using place holder
Console.WriteLine("Full Name {0} {1}",first_Name ,last_Name);
// here print full using concatenation string
Console.WriteLine("Full Name "+first_Name+last_Name);
Console.ReadLine();
}
}
Output:
No comments:
Post a Comment