C#

Reading and writing to a console in C#

Suggested Videos

Part 1 – Introduction to C#

In this video, we will discuss
1. Reading from the console
2. Writing to the console
3. Two ways to write to console
a) Concatenation
b) Place holder syntax – Most preferred

Code samples used in the demo
using System;
class Program
{
static void Main()
{
// Prompt the user for his name
Console.WriteLine(“Please enter your name”);
// Read the name from console
string UserName = Console.ReadLine();
// Concatenate name with hello word and print
Console.WriteLine(“Hello ” + UserName);

//Placeholder syntax to print name with hello word
//Console.WriteLine(“Hello {0}”, UserName);
}
}

Please note that C# is case sensitive language.
[youtube https://www.youtube.com/watch?v=6QcHJ33YrYk?rel=0&showinfo=0&w=560&h=315]

KhalidAhmed
Khalid Ahmed

Expert .NET Full-Stack Developer with 10+ years building scalable business applications. Proficient in C#, ASP.NET Core, Angular, SQL, and Azure Cloud. Strong background in SDLC, APIs, microservices, and DevOps. Delivers high-performance solutions aligned with business needs. Let’s innovate together!

Khalid Ahmed

Expert .NET Full-Stack Developer with 10+ years building scalable business applications. Proficient in C#, ASP.NET Core, Angular, SQL, and Azure Cloud. Strong background in SDLC, APIs, microservices, and DevOps. Delivers high-performance solutions aligned with business needs. Let’s innovate together!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button