This article mainly hopes to help students who want to learn C# and .NET technology stack to find the way to get started!
Microsoft provides a full set of C# documentation on the official website, providing complete guidance from introductory to proficient.
Official document address: automatic/English/Chinese
- English original: https://docs.microsoft.com/en-us/dotnet/csharp/
- Chinese version: https://docs.microsoft.com/zh-cn/dotnet/csharp/
Due to long-term accumulation, C# official documentation provides more content, but it is more messy and not very friendly to beginners. For those who have already learned C#, it is very useful as a reference and knowledge point finding tool. However, the official documentation provides the most complete and detailed learning content. Beginners can follow the guide and learn the basics of C# here.
For beginners, start with "C# Basics".
Introduction to C# Basics
The first chapter "Getting Started" is mainly an introduction to C# and its environment. You can read it thoroughly without chewing it carefully. Most of the concepts mentioned in this chapter will be described in detail in the "C# Programming Guide" and "Language Reference" sections.
Among them, "Introduction to the C# Language" introduces C# and the .NET architecture. C# and .NET are inseparable. It can be said that C# is a language invented for .NET, so while learning C#, you must understand .NET. When learning any language, there are two key points: one is the grammar itself, and the other is the API library (function library/class library, etc.) that supports the language. .NET SDK provides a basic and comprehensive API library for C#.
The "Tutorial" part is mainly taught in two forms. The "Browser-based Tutorial" allows you to understand some basic concepts of C# development step by step on the browser. But after completing the "browser-based tutorial", don't ignore "working in the local environment", which is the practical part, which is to write C# programs in a real day-to-day work environment. This part introduces command line-based C# project operations and Visual Studio 2019/2022-based C# project operations, and it is recommended to learn the latter directly. Based on the partial understanding of dotnet CLI, you can learn more when you have finished learning C# and in-depth advanced knowledge of C# construction technology and continuous integration.
The "Basics" section of Chapter 2 requires a thorough reading. The content of this section is best practiced dotnetfiddle.net The "Object Oriented Programming" part needs to be read carefully. If you have a foundation in C++ or Java, this part may be easier to read; if you have not studied OOP (Object Oriented Programming, object-oriented programming), you can refer to other relevant bookcases or materials to aid reading comprehension. Note that the "polymorphism" mentioned here is called "polymorphism" in most books.
"What's new in C#" If you are interested, you can learn about it. This is the development history of the C# language. This is mainly for programmers who have learned C#, providing a way to quickly understand the new syntax and functions.
The rest of the content can be skipped until the "C# Programming Guide".
C# Programming Guide Introduction
The "C# Programming Guide" section provides a relatively complete introduction to the basic concepts of "programming" and the language features and syntax of C#. This chapter is mainly to introduce concepts and theories, so if there are some things that you can't understand, you can remember them first, and then gradually understand them in practice.
Among them, read through the "Programming Concepts" section in order to understand various basic concepts of programming and C# programming. If the understanding of "programming" and "C#" is not deep enough, it may be difficult to understand and memorize this part of the content, so it is not necessary to study it carefully for the time being. After completing the learning of the C# language, go back and read the "Programming Concepts" section carefully again, strive to understand it with the knowledge of C# you have learned, and consolidate it through practice (writing code).
When studying the content of this chapter, there may be some reference links to the "specification" that cannot be opened. No problem, these are also covered in the "Language Reference" chapter.
C# Language Reference Guide
The "Language Reference" section describes the syntax elements of C# in detail, and is also learned by reading and practicing. Remember, however, that various code snippets are provided here, all of which can only allow the reader to understand the corresponding syntax one-sidedly. To make a flexible application of the C# language, it is necessary to constantly write and optimize the code in practice. Optimizing code, in particular, is the easiest thing for beginners to ignore. Writing code is like writing articles. Every once in a while, look back and you may find areas that can be optimized - this shows that you are making progress. So sometimes the comprehensive practice code that I have written (basic practice is not necessary, at least it should be a logically complete programming goal), you might as well write it again after a while.
C# is a strongly typed language, so the "types" part is very basic and very important. The difference between value types and reference types is recommended to be understood in conjunction with the concepts of heap and stack in courses related to computer composition principles. If you have learned C/C++, you can understand references through pointers. It should be noted that the reference of C# and the reference of C++ are two different concepts - the reference concept of C# is more like a C/C++ pointer without computing power; while the parameters of C# function parameters are modified ref
and out
It is closer to the concept of C++ references.
When learning grammar, you may find that some grammars are actually convenient writing methods for developers, which we habitually call "syntactic sugar". For example, using var
to declare variables is a syntactic sugar, which allows developers to write fewer characters when declaring variables. However, syntactic sugar is usually applicable. Please pay attention to its application scenarios and the real meaning it represents, and do not ignore its essence because of convenience.
"Keywords" are mainly used to support language features, and simply learning keywords cannot achieve good results. It is recommended for users who understand keywords and understand related concepts in the "C# Programming Guide". For example, "access modifiers" relate to the visibility of command space, classes and members; abstract
and interface
relate to abstract concepts in OOP; virtual
and override
relate to OOP polymorphism and so on. There are also some keywords related to more advanced language features, such as extern
, volatile
etc., you can understand it first, know that there is such a thing, and then understand it when you learn and use the relevant advanced features.
When learning a method, you should be able to understand that a method is also a function, which can be compared/analogous to other function representations, such as delegation and Lambda.
When learning operators and expressions, we need to understand the difference between expressions and statements. Why do we need expressions? What do operators and functions do in expressions? Of course, don't forget to learn about operator precedence. It may be difficult to remember the operator optimization level completely, but please remember the location of the operator precedence table for future reference; also don't ignore the ()
in clarifying the operation precedence.
summary
The so-called language, in fact, does not involve a lot of content, but is nothing more than the language features and syntax corresponding to various programming concepts. For most programming languages, the language bases are nothing more than constants, variables, expressions, functions, and statements, as well as procedural-oriented programs (sequences, branches, loops) and object-oriented programs (interfaces, classes, and objects).
Any language will have a standard library, as well as some idiomatic libraries. For example, C++ has cstdlib/stdlib.h, STL (Standard Template Library), Boost, etc.; Java has JDK, etc. The standard library of C# is provided by .NET, and .NET is divided into several architecture categories: .NET Framework, .NET Core and .NET 5+. It is recommended to directly use the latest version of Visual Studio (currently 2022) or the next latest version (currently 2019), and practice based on .NET 6 or .NET 5. Since .NET 5/6 is relatively new, there are not many books that can be found. You can find a book box related to .NET Core (recommended 3.0+) to learn by analogy, and the difference between them is not very big.
More and more language systems provide API repositories, such as Maven for Java and npm for JavaScript. The .NET system to which C# belongs provides the NuGet repository , where you can find a variety of libraries to speed up program development. However, in actual use, you should pay attention to evaluation and screening, and choose a suitable and ecologically healthy library.
After learning the basics of C#, it is recommended to read two comprehensive C# programming book boxes to be familiar with the use of C# in projects, especially the use of ASP.NET . In the process of in-depth learning, don’t forget to use the tools well. Visual Studio is the best tool for C# development. You must be good at discovering, summarizing and sharing IDE usage skills, understanding IDE functions and excellent extensions (plug-ins), and mastering them proficiently. Common shortcut keys to create (configure) the IDE into a high-efficiency development tool that suits you.
Attachment: Recommended Book List
The following books can be found in Dangdang, Jingdong and other shopping malls. Since software development technology is changing with each passing day, please try to read the latest version and avoid wasting your energy on some outdated or updated technology. Of course it's helpful to have time to learn about technological developments, but that's not the point of a beginner.
- C# Beginner Classic: Updating to C# 9 and .NET 5
- "CLR via C# (4th Edition)"
- "ASP.NET Core 3 Advanced Programming (8th Edition)"
- "In-depth explanation of ASP.NET Core"
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。