mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
style: autoformat
This commit is contained in:
@@ -5,14 +5,15 @@ created_at: 2022/10/31
|
||||
title: Basic information about .NET and C#
|
||||
---
|
||||
|
||||
## What is C#?
|
||||
## What is C#?
|
||||
|
||||
It's a modern, object-oriented, component-oriented, type-safe language with the support of functional programming techniques.
|
||||
|
||||
It's multi-paradigm: *structured, imperative, object-oriented, event-driven, task-driven, functional, generic, reflective, concurrent*
|
||||
It's multi-paradigm: _structured, imperative, object-oriented, event-driven, task-driven, functional, generic, reflective, concurrent_
|
||||
|
||||
C# has many features to develop robust and durable applications.
|
||||
|
||||
- Garbage collections take care of automatically reclaiming occupied memory by unreachable unused objects.
|
||||
- Garbage collections take care of automatically reclaiming occupied memory by unreachable unused objects.
|
||||
|
||||
- Nullable types guard against variables that don't refer to allocated objects.
|
||||
|
||||
@@ -26,35 +27,38 @@ C# has many features to develop robust and durable applications.
|
||||
|
||||
- C# has a `unified type system`. All types inherit from a single root `object` type. Values of any type can be stored, transported, and operated upon in a consistent manner.
|
||||
|
||||
- C# supports both `value types` and `reference types`. C# allows dynamic allocation of objects and in-line storage of lightweight structures.
|
||||
- C# supports both `value types` and `reference types`. C# allows dynamic allocation of objects and in-line storage of lightweight structures.
|
||||
|
||||
- C# supports generic methods and types, which provide increased type safety and performance.
|
||||
|
||||
- C# provides iterators that enable implementers of collection classes to define custom behaviors for client code.
|
||||
- C# provides iterators that enable implementers of collection classes to define custom behaviors for client code.
|
||||
|
||||
## .NET architecture
|
||||
|
||||
C# programs run on .NET, a virtual execution system called the common language runtime (`CLR`).
|
||||
|
||||
The `CLR` is implementation by Microsoft of the common language infrastructure (`CLI`), an international standard. The CLI is the basis for creating execution and development environments in which languages and libraries work together seamlessly.
|
||||
The `CLR` is implementation by Microsoft of the common language infrastructure (`CLI`), an international standard. The CLI is the basis for creating execution and development environments in which languages and libraries work together seamlessly.
|
||||
|
||||
Source code written in C# is compiled into an `intermediate language (IL)` which is `byte code` that conforms to the `CLI` specification.
|
||||
The `IL` code and resources such as bitmaps and string, are stored in an assembly, typically with an extension of `.dll`. An assembly contains a manifest that provides information about the assembly's types, version, and culture.
|
||||
|
||||
When the C# program is executed, the assembly is loaded into the `CLR`. The CLR performs a `Just-In-Time` (`JIT`) compilation to convert the `IL` code to native machine instruction.
|
||||
When the C# program is executed, the assembly is loaded into the `CLR`. The CLR performs a `Just-In-Time` (`JIT`) compilation to convert the `IL` code to native machine instruction.
|
||||
|
||||
The CLR provides other services related to automatic garbage collection, exception handling, and resource management. Code that's executed by the CLR is sometimes referred to as "managed code."
|
||||
The CLR provides other services related to automatic garbage collection, exception handling, and resource management. Code that's executed by the CLR is sometimes referred to as "managed code."
|
||||
|
||||
"Unmanaged code" is compiled into a native machine language that targets a specific platform.
|
||||
|
||||
Language interoperability is a key feature of .NET. IL code produced by the C# compiler conforms to the `Common Type Specification` (`CTS`). IL code generated from C# can interact with code that was generated from the .NET version of F#, VB, and C++.
|
||||
|
||||
There are more than 20 other CTS-compliant languages. A single assembly may contain multiple modules written in indifferent .NET languages. The types can reference each other as if they were written in the same language.
|
||||
There are more than 20 other CTS-compliant languages. A single assembly may contain multiple modules written in indifferent .NET languages. The types can reference each other as if they were written in the same language.
|
||||
The types can reference each other as if they were written in the same language.
|
||||
|
||||
In addition to the run time services, .NET also includes extensive libraries like `Base Class Library` (`BCL`). These libraries support many different workloads. They're organized into namespaces that provide a wide variety of useful functionality. The libraries include everything from file input and output to string manipulation to XML parsing, to web application frameworks to Windows Forms controls. The typical C# app uses the .NET class library extensively to handle common "plumbing" chores.
|
||||
In addition to the run time services, .NET also includes extensive libraries like `Base Class Library` (`BCL`). These libraries support many different workloads. They're organized into namespaces that provide a wide variety of useful functionality. The libraries include everything from file input and output to string manipulation to XML parsing, to web application frameworks to Windows Forms controls. The typical C# app uses the .NET class library extensively to handle common "plumbing" chores.
|
||||
|
||||
> Fully defined **Hello World** program
|
||||
|
||||
## Hello World
|
||||
|
||||
```cs
|
||||
using System;
|
||||
|
||||
@@ -74,10 +78,7 @@ The `Hello` class has a single member, the method `Main`. `Main` method is decla
|
||||
<br />
|
||||
|
||||
> New minimalistic approach (since .NET 6)
|
||||
|
||||
```cs
|
||||
Console.WriteLine("Hello World");
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user