C# 教程C# Tutorials

欢迎学习 C# 教程。Welcome to the C# tutorials. 本系列教程从可以在浏览器中演练的交互式课程入手。These start with interactive lessons that you can run in your browser. 后面的教程和更高级的教程可帮助你使用 .NET 开发工具在你的计算机上创建 C# 程序。Later tutorials and more advanced tutorials help you work with the .NET development tools to create C# programs on your machine.

C# 交互式教程简介Introduction to C# interactive tutorials

头几个课程通过小篇幅的代码片段介绍了 C# 概念。The first lessons explain C# concepts using small snippets of code. 读者将了解 C# 语法的基础知识,以及如何使用字符串、数字和布尔值等数据类型。You'll learn the basics of C# syntax and how to work with data types like strings, numbers, and booleans. 全都是交互式课程,读者可以在几分钟内编写并运行代码。It's all interactive, and you'll be writing and running code within minutes. 无需事先了解编程或 C# 语言,即可学习头几个课程。These first lessons assume no prior knowledge of programming or the C# language.

Hello WorldHello world

Hello world 教程中,你将创建最基本的 C# 程序。In the Hello world tutorial, you'll create the most basic C# program. 读者将探索 string 类型以及如何使用文本。You'll explore the string type and how to work with text.

C# 中的数字Numbers in C#

C# 中的数字教程中,将了解计算机如何存储数字,以及如何对不同类型的数字执行计算。In the Numbers in C# tutorial, you'll learn how computers store numbers and how to perform calculations with different numeric types. 读者将学习四舍五入的基础知识,以及如何使用 C# 执行数学运算。You'll learn the basics of rounding, and how to perform mathematical calculations using C#. 本教程也可下载到计算机本地进行学习This tutorial is also available to run locally on your machine.

若要更好地学习本教程,需要已完成 Hello world 课程。This tutorial assumes that you have finished the Hello world lesson.

分支和循环Branches and loops

分支和循环教程中,将了解根据变量中存储的值选择不同代码执行路径的基础知识。The Branches and loops tutorial teaches the basics of selecting different paths of code execution based on the values stored in variables. 读者将学习控制流的基础知识,这是程序决定选择不同操作的基本依据。You'll learn the basics of control flow, which is the basis of how programs make decisions and choose different actions. 本教程也可下载到计算机本地进行学习This tutorial is also available to run locally on your machine.

若要更好地学习本教程,需要先完成 Hello WorldC# 中的数字课程。This tutorial assumes that you have finished the Hello world and Numbers in C# lessons.

列表集合List collection

列表集合课程将介绍存储一系列数据的列表集合类型。The List collection lesson gives you a tour of the List collection type that stores sequences of data. 读者将学习如何添加和删除项、如何搜索项,以及如何对列表进行排序。You'll learn how to add and remove items, search for items, and sort the lists. 读者将探索各种列表。You'll explore different kinds of lists. 本教程也可下载到计算机本地进行学习This tutorial is also available to run locally on your machine.

若要更好地学习本教程,需要已完成上面列出的课程。This tutorial assumes that you have finished the lessons listed above.

C# 简介 -- 在本地工作Introduction to C# -- work locally

可以在自己的本地开发环境中学习 Hello World 课程之后的所有入门教程。All the introductory tutorials following the Hello World lesson are available in your own local development environment. 每个教程结束时,可以决定是继续在线学习还是在自己的计算机上学习下一节课程。At the end of each tutorial, you decide if you want to continue with the next lesson online or on your own machine. 可以访问相关链接设置自己的环境并继续在自己的计算机上学习下一个教程。There are links to help you setup your environment and continue with the next tutorial on your machine.

探索 C# 中的新增功能Explore new features in C#

常规教程General Tutorials

下面各教程介绍了如何使用 .NET Core 生成 C# 程序:The following tutorials enable you to build C# programs using .NET Core:

  • 控制台应用程序:介绍了控制台 I/O、控制台应用程序的结构,以及基于任务的异步编程模型的基础知识。Console Application: demonstrates Console I/O, the structure of a Console application, and the basics of the task-based asynchronous programming model.
  • REST 客户端:介绍了 Web 通信、JSON 序列化和面向对象的 C# 语言功能。REST Client: demonstrates web communications, JSON serialization, and object-oriented features in the C# language.
  • C# 和 .NET 中的继承:介绍了 C# 中的继承,包括使用继承来定义基类、抽象基类和派生类。Inheritance in C# and .NET: demonstrates inheritance in C#, including the use of inheritance to define base classes, abstract base classes, and derived classes.
  • 使用 LINQ:介绍了许多 LINQ 功能和支持 LINQ 的语言元素。Working with LINQ: demonstrates many of the features of LINQ and the language elements that support it.
  • 使用特性:介绍了如何借助 C# 创建和使用特性。Using Attributes: demonstrates how to create and use attributes in C#.
  • 字符串内插教程将介绍如何将值插入到字符串中。String interpolation tutorial shows you how to insert values into a string. 你将学习如何创建带有嵌入式 C# 表达式的内插字符串,以及如何控制结果字符串中表达式结果的文本外观。You'll learn how to create an interpolated string with embedded C# expressions and how to control the text appearance of the expression results in the result string. 本教程也可下载到计算机本地进行学习This tutorial is also available to run locally on your machine.