You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/tour-of-csharp/index.md
+7-56Lines changed: 7 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,76 +6,27 @@ ms.date: 05/19/2020
6
6
7
7
# A tour of the C# language
8
8
9
-
## Hello World
9
+
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers. This tour provides an overview of the major components of the language in C# 8 and earlier. If you want to explore the language through interactive examples, try the [introduction to C#](../tutorials/intro-to-csharp/index.md) tutorials.
10
10
11
-
## Program structure
11
+
C# is an object-oriented, ***component-oriented*** programming. C# provides language constructs to support directly these concepts, making C# a natural language in which to create and use software components. Since its inception, C# has added features to support new workloads and emerging software design practices.
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers.
21
-
22
-
This tour provides an overview of the major components of the language in C# 8 and earlier. If you want to explore the language through interactive examples, try the [introduction to C#](../tutorials/intro-to-csharp/index.md) tutorials.
23
-
24
-
C# is an object-oriented language, but C# further includes support for ***component-oriented*** programming. Contemporary software design increasingly relies on software components in the form of self-contained and self-describing packages of functionality. C# provides language constructs to support directly these concepts, making C# a natural language in which to create and use software components. Since its inception, C# has added features to support modern workloads and software design practices.
25
-
26
-
Several C# features aid in the construction of robust and durable applications. ***Garbage collection*** automatically reclaims memory occupied by unreachable unused objects. ***Exception handling*** provides a structured and extensible approach to error detection and recovery. The ***type-safe*** design of the language makes it impossible to read from uninitialized variables, to index arrays beyond their bounds, or to perform unchecked type casts. **Lambda expressions** suppport functional programming techniques. **Query syntax** creates a common pattern for working with data from any source. Language support for **asynchronous operations** provides syntax for building distributed systems. **Pattern matching** provides syntax to easily separate data from algorithms in modern distributed systems.
27
-
28
-
C# has a ***unified type system***. All C# types, including primitive types such as `int` and `double`, inherit from a single root `object` type. Thus, all types share a set of common operations, and values of any type can be stored, transported, and operated upon in a consistent manner. Furthermore, C# supports both user-defined reference types and value types, allowing dynamic allocation of objects as well as in-line storage of lightweight structures.
13
+
Several C# features aid in the construction of robust and durable applications. ***Garbage collection*** automatically reclaims memory occupied by unreachable unused objects. ***Exception handling*** provides a structured and extensible approach to error detection and recovery. ***Lambda expressions*** suppport functional programming techniques. ***Query syntax*** creates a common pattern for working with data from any source. Language support for ***asynchronous operations*** provides syntax for building distributed systems. ***Pattern matching*** provides syntax to easily separate data from algorithms in modern distributed systems. C# has a ***unified type system***. All C# types, including primitive types such as `int` and `double`, inherit from a single root `object` type. Thus, all types share a set of common operations, and values of any type can be stored, transported, and operated upon in a consistent manner. Furthermore, C# supports both user-defined reference types and value types, allowing dynamic allocation of objects as well as in-line storage of lightweight structures.
29
14
30
15
To ensure that C# programs and libraries can evolve over time in a compatible manner, much emphasis has been placed on ***versioning*** in C#'s design. Aspects of C#'s design that were directly influenced by versioning considerations include the separate `virtual` and `override` modifiers, the rules for method overload resolution, and support for explicit interface member declarations.
31
16
32
17
## Hello world
33
18
34
19
The "Hello, World" program is traditionally used to introduce a programming language. Here it is in C#:
C# source files typically have the file extension `.cs`. To create this program, first download and install the [.NET Core SDK](https://dotnet.microsoft.com/download). Then, execute the command `dotnet new console -o hello` to create a new program and a build script. The program and build script are in the files `Program.cs` and `hello.csproj`, respectively. You build and run the application with the `run` commands:
The "Hello, World" program starts with a `using` directive that references the `System` namespace. Namespaces provide a hierarchical means of organizing C# programs and libraries. Namespaces contain types and other namespaces—for example, the `System` namespace contains a number of types, such as the `Console` class referenced in the program, and a number of other namespaces, such as `IO` and `Collections`. A `using` directive that references a given namespace enables unqualified use of the types that are members of that namespace. Because of the `using` directive, the program can use `Console.WriteLine` as shorthand for `System.Console.WriteLine`.
52
24
53
25
The `Hello` class declared by the "Hello, World" program has a single member, the method named `Main`. The `Main` method is declared with the `static` modifier. While instance methods can reference a particular enclosing object instance using the keyword `this`, static methods operate without reference to a particular object. By convention, a static method named `Main` serves as the entry point of a program.
54
26
55
27
The output of the program is produced by the `WriteLine` method of the `Console` class in the `System` namespace. This class is provided by the standard class libraries, which, by default, are automatically referenced by the compiler.
56
28
57
-
## Elements of the C# language
58
-
59
-
There's a lot more to learn about C#. The following topics provide an overview of the elements of the C# language. These overviews provide basic information about all elements of the language and give you the information necessary to dive deeper:
60
-
61
-
-[Program Structure](program-structure.md)
62
-
- Learn the key organizational concepts in the C# language: ***programs***, ***namespaces***, ***types***, ***members***, and ***assemblies***.
63
-
-[Types and Variables](types-and-variables.md)
64
-
- Learn about ***value types***, ***reference types***, and ***variables*** in the C# language.
65
-
-[Expressions](expressions.md)
66
-
-***Expressions*** are constructed from ***operands*** and ***operators***. Expressions produce a value.
67
-
-[Statements](statements.md)
68
-
- You use ***statements*** to express the actions of a program.
69
-
-[Classes and objects](classes-and-objects.md)
70
-
-***Classes*** are the most fundamental of C#'s types. ***Objects*** are instances of a class. Classes are built using ***members***, which are also covered in this topic.
71
-
-[Arrays](arrays.md)
72
-
- An ***array*** is a data structure that contains a number of variables that are accessed through computed indices.
73
-
-[Interfaces](interfaces.md)
74
-
- An ***interface*** defines a contract that can be implemented by classes and structs. An interface can contain methods, properties, events, and indexers.
75
-
-[Delegates](delegates.md)
76
-
- A ***delegate type*** represents references to methods with a particular parameter list and return type. Delegates make it possible to treat methods as data. Delegates are object-oriented and type-safe objects that can be used like function pointers.
77
-
-[Attributes](attributes.md)
78
-
-***Attributes*** enable programs to specify additional declarative information about types, members, and other entities.
29
+
Further articles in this tour explain these organizational blocks. << CONSIDER COMBINING FILES >>
0 commit comments