C# 教程

C# 是什么、它跑在哪、这套教程怎么学。

Beginner
Key PointsC# 编译成 IL,由 CLR 在 .NET 上执行;一次编写,多平台运行。

C# 是什么

C# is Microsoft's object-oriented language from 2000, designed by Anders Hejlsberg (also behind Delphi and TypeScript). It runs on .NET: source compiles to IL, then the CLR JIT-compiles to machine code at runtime.

C#
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, C#!");
    }
}
Output
Hello, C#!

能做什么

AreaTech
Web 后端ASP.NET Core
桌面应用WPF、WinForms、MAUI、Avalonia
游戏Unity(C# 是主语言)
云服务Azure Functions、微服务
跨平台移动MAUI
CLI 工具System.CommandLine、Spectre.Console

和 Java 的关系

Syntactically C# and Java are close (both shaped by C++), but C# evolves faster: LINQ, async/await, records, Span<T> and nullable reference types all landed in C# first. Java adopted some later.

学习路线

  1. 装 .NET SDK,跑通第一个 dotnet run
  2. 语法 —— 类型、变量、流程控制、方法
  3. 面向对象 —— 类、继承、多态、接口
  4. 常用库 —— 字符串、集合、LINQ、文件
  5. 进阶 —— 委托、事件、泛型、反射、多线程
Examples are verified on .NET 8/9 using top-level statements (no class Program needed). The older static void Main style still works — both run.

Friends & Partners