Introduction to C#
What is C#?
C# (pronounced "C-sharp") is a modern, object-oriented programming language developed by Microsoft as part of the .NET framework. It was designed by Anders Hejlsberg and his team at Microsoft and released in 2002. C# is one of the most popular programming languages in the world, used for building a wide variety of applications.
Key Fact
C# was designed to be simple, modern, and type-safe. It combines the power of C++ with the simplicity of Visual Basic.
Why Learn C#?
Desktop Apps
Build Windows desktop applications with Windows Forms and WPF
Web Development
Create web applications with ASP.NET Core
Mobile Apps
Build cross-platform apps with .NET MAUI and Xamarin
Game Development
Create games with Unity game engine
Cloud Services
Build cloud-native applications on Azure
IoT & Embedded
Develop Internet of Things applications
C# Features
- Object-Oriented: Supports classes, inheritance, polymorphism, and encapsulation
- Type-Safe: Strong typing prevents common programming errors
- Automatic Memory Management: Garbage collection handles memory allocation
- Modern Language Features: LINQ, async/await, pattern matching, and more
- Cross-Platform: Run on Windows, Linux, and macOS with .NET Core
- Rich Standard Library: Extensive framework for common programming tasks
Your First C# Program
Let's look at the traditional "Hello World" program in C#:
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
Understanding the Code
- using System; - Imports the System namespace
- class Program - Defines a class named Program
- static void Main() - The entry point of the program
- Console.WriteLine() - Outputs text to the console
Key Takeaway
C# is a versatile, modern language that can be used to build almost any type of application. It's a great choice for beginners and experienced developers alike.
What's Next?
In the next lesson, we'll set up your development environment and get you ready to write your first C# program. Make sure you have Visual Studio installed, or we'll guide you through the installation.