C# Tutorial
Learn C# programming from scratch
🚀 Welcome to C# Programming!
C# (C-Sharp) is a modern, powerful programming language developed by Microsoft. It's perfect for building desktop apps, games, web applications, and mobile apps with ease and efficiency.
// Your first C# program
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, C#!");
}
}
Output:
Hello, C#!
Why Learn C#?
Professional
Used by major companies worldwide for enterprise applications
Game Development
Power Unity game engine to create amazing games
Web & Mobile
Build web apps with ASP.NET and mobile apps with Xamarin
Easy to Learn
Clear syntax and excellent documentation for beginners
🔹 What You'll Learn
This tutorial covers everything you need to start programming in C#:
- C# Basics: Syntax, variables, and data types
- Control Flow: If statements, loops, and switches
- Functions: Methods and parameters
- Object-Oriented: Classes, objects, and inheritance
- Collections: Arrays, lists, and dictionaries
- Error Handling: Try-catch and exceptions
🔹 Quick Example
See how easy C# is! This program calculates the sum of two numbers:
using System;
class Calculator
{
static void Main()
{
int num1 = 10;
int num2 = 20;
int sum = num1 + num2;
Console.WriteLine("Sum: " + sum);
}
}
Output:
Sum: 30
🔹 C# Applications
C# is versatile and can be used for many types of applications:
Desktop Applications
Create Windows applications with WPF or Windows Forms
// Simple Windows app
MessageBox.Show("Hello from C#!");
Web Applications
Build powerful web apps using ASP.NET Core
// Web API endpoint
[HttpGet]
public string GetMessage()
{
return "Hello from Web API!";
}
Game Development
Create games with Unity game engine
// Unity game script
void Start()
{
Debug.Log("Game Started!");
}
🔹 Getting Started
Ready to begin your C# journey? Follow these steps:
- Read the C# Introduction to understand the basics
- Follow C# Get Started to set up your environment
- Learn C# Syntax to write your first programs
- Practice with examples and build your own projects