Member-only story
Introduction
C# is a powerful, object-oriented programming language developed by Microsoft, widely used for developing desktop, web, and mobile applications. In this guide, we’ll walk through creating and executing a basic C# program with an interactive twist.
Your First C# Program
Traditionally, the first program beginners write is “Hello World.” However, let’s make it more engaging by creating a personalized greeting program.
Code Example: A Personalized Greeting
using System;
class GreetingApp
{
static void Main()
{
Console.Write("Enter your name: ");
string userName = Console.ReadLine();
Console.Write("Enter your favorite programming language: ");
string favoriteLanguage = Console.ReadLine();
Console.WriteLine("\\nHello, " + userName + "! You love " + favoriteLanguage + ", that's awesome!");
}
}
Explanation of Code:
- Using System; → This imports basic functions, including
Console.ReadLine()
andConsole.WriteLine()
. - Console.Write() → Displays a prompt to take user input on the same line.
- Console.ReadLine() → Captures input from…