C# 是由 Microsoft 创建的现代、静态类型的面向对象语言。.NET 是它运行的平台——一个运行时、一个庞大的标准库,以及用于构建多种应用程序的工具。现代 .NET 是跨平台、开源和高性能的。
一个简单的 C# 程序
csharp
System;
Console.WriteLine();
=> a + b;
✓ Statically typed — types checked at compile time (catch errors early)
✓ Object-oriented — classes, interfaces, inheritance (also functional features)
✓ Modern & expressive — LINQ, async/await, pattern matching, records, nullable refs
✓ Memory-managed — garbage collection (no manual free)
✓ Compiled — to IL (Intermediate Language), then JIT-compiled to native at runtime
✓ CLR (Common Language Runtime) — executes code, manages memory (GC), JIT compiles IL
✓ Base Class Library (BCL) — huge standard library (collections, IO, networking, ...)
✓ Cross-platform — modern .NET runs on Windows, Linux, macOS (open-source)
✓ One platform, many app types (below)
✓ Web apps & APIs — ASP.NET Core (high-performance web framework)
✓ Desktop — WPF, WinForms, MAUI (also mobile)
✓ Cloud services & microservices, games (Unity uses C#), IoT, ML.NET
.NET Framework (legacy) → Windows-only, the original
Modern .NET (Core / .NET 5+) → cross-platform, open-source, faster — the current standard
理解 C# 和 .NET 是在 Microsoft 生态系统及其他地方进行开发的基础背景。
关键点:C# 是一种现代、静态类型的面向对象(并且越来越多函数式)语言,表现力强且功能丰富(LINQ、async/await、records、模式匹配),而 .NET 是它运行的强大平台——提供 CLR 运行时(具有垃圾回收和 JIT 编译)、庞大的标准库,以及用于构建几乎任何类型应用程序的工具(使用 ASP.NET Core 的 web API、桌面、移动、云、通过 Unity 的游戏)。
重要的是,现代 .NET(Core / .NET 5+)已经演变为一个跨平台、开源、高性能的平台(从遗留的仅限 Windows 的 .NET Framework 发生了重大转变),使 C# 在 Windows 之外也很有意义。
认识 C# 的性质、.NET 平台的组件和广泛范围,以及现代与遗留的区分确立了关于在该生态系统中工作的其他一切——并解释了为什么 C#/.NET 是企业应用程序、高性能 web 服务和许多其他领域的主要选择。