Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/csharp/basic-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ms.assetid: 95c686ba-ae4f-440e-8e94-0dbd6e04d11f

# Types, variables, and values

C# is a strongly typed language. Every variable and constant has a type, as does every expression that evaluates to a value. Every method signature specifies a type for each input parameter and for the return value. The .NET Framework class library defines a set of built-in numeric types as well as more complex types that represent a wide variety of logical constructs, such as the file system, network connections, collections and arrays of objects, and dates. A typical C# program uses types from the class library as well as user-defined types that model the concepts that are specific to the program's problem domain.
C# is a strongly typed language. Every variable and constant has a type, as does every expression that evaluates to a value. Every method signature specifies a type for each input parameter and for the return value. The .NET class library defines a set of built-in numeric types as well as more complex types that represent a wide variety of logical constructs, such as the file system, network connections, collections and arrays of objects, and dates. A typical C# program uses types from the class library as well as user-defined types that model the concepts that are specific to the program's problem domain.

The information stored in a type can include the following:

Expand Down Expand Up @@ -53,11 +53,11 @@ C# provides a standard set of built-in numeric types to represent integers, floa

## Custom types

You use the [struct](language-reference/builtin-types/struct.md), [class](language-reference/keywords/class.md), [interface](language-reference/keywords/interface.md), and [enum](language-reference/builtin-types/enum.md) constructs to create your own custom types. The .NET Framework class library itself is a collection of custom types provided by Microsoft that you can use in your own applications. By default, the most frequently used types in the class library are available in any C# program. Others become available only when you explicitly add a project reference to the assembly in which they are defined. After the compiler has a reference to the assembly, you can declare variables (and constants) of the types declared in that assembly in source code.
You use the [struct](language-reference/builtin-types/struct.md), [class](language-reference/keywords/class.md), [interface](language-reference/keywords/interface.md), and [enum](language-reference/builtin-types/enum.md) constructs to create your own custom types. The .NET class library itself is a collection of custom types provided by Microsoft that you can use in your own applications. By default, the most frequently used types in the class library are available in any C# program. Others become available only when you explicitly add a project reference to the assembly in which they are defined. After the compiler has a reference to the assembly, you can declare variables (and constants) of the types declared in that assembly in source code.

## Generic types

A type can be declared with one or more *type parameters* that serve as a placeholder for the actual type (the *concrete type*) that client code will provide when it creates an instance of the type. Such types are called *generic types*. For example, the .NET Framework type <xref:System.Collections.Generic.List%601> has one type parameter that by convention is given the name *T*. When you create an instance of the type, you specify the type of the objects that the list will contain, for example, string:
A type can be declared with one or more *type parameters* that serve as a placeholder for the actual type (the *concrete type*) that client code will provide when it creates an instance of the type. Such types are called *generic types*. For example, <xref:System.Collections.Generic.List%601> has one type parameter that by convention is given the name *T*. When you create an instance of the type, you specify the type of the objects that the list will contain, for example, string:

[!code-csharp[Generic types](../../samples/snippets/csharp/concepts/basic-types/generic-type.cs)]

Expand All @@ -73,7 +73,7 @@ It's common to want to return more than one value from a method. You can create

## The Common type system

It is important to understand two fundamental points about the type system in the .NET Framework:
It is important to understand two fundamental points about the type system in .NET:

- It supports the principle of inheritance. Types can derive from other types, called *base types*. The derived type inherits (with some restrictions) the methods, properties, and other members of the base type. The base type can in turn derive from some other type, in which case the derived type inherits the members of both base types in its inheritance hierarchy. All types, including built-in numeric types such as <xref:System.Int32> (C# keyword: `int`), derive ultimately from a single base type, which is <xref:System.Object> (C# keyword: `object`). This unified type hierarchy is called the [Common type system](../standard/common-type-system.md) (CTS). For more information about inheritance in C#, see [Inheritance](programming-guide/classes-and-structs/inheritance.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/codedoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You can generate the XML file at compile time by doing one of the following:

- If you are developing an application using Visual Studio, right-click on the project and select **Properties**. In the properties dialog, select the **Build** tab, and check **XML documentation file**. You can also change the location to which the compiler writes the file.

- If you are compiling a .NET Framework application from the command line, add the [-doc compiler option](language-reference/compiler-options/doc-compiler-option.md) when compiling.
- If you are compiling a .NET application from the command line, add the [-doc compiler option](language-reference/compiler-options/doc-compiler-option.md) when compiling.

XML documentation comments use triple forward slashes (`///`) and an XML formatted comment body. For example:

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This section provides short, simple tutorials that let you quickly build an appl

The following topics are available:

- [Introduction to the C# language and the .NET Framework](introduction-to-the-csharp-language-and-the-net-framework.md)
- [Introduction to the C# language and .NET](introduction-to-the-csharp-language-and-the-net-framework.md)

Provides an overview of the C# language and .NET.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: "Introduction to the C# Language and the .NET Framework"
title: "Introduction to the C# Language and .NET"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This article needs to be reviewed carefully to make sure the information provided in it are not .NET Framework-specific. Then it may be worth renaming the file and adding a redirection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillWagner This is an ancient intro to C#. My inclination is to retire it and redirect to the new Tour of C#. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's on my plan for part of this release cycle (probably next month).

description: Learn the basics of C# and .NET. Get an overview of the C# language and .NET ecosystem.
ms.date: 07/20/2015
helpviewer_keywords:
- "C# language, about C# language"
- "Visual C#, about"
ms.assetid: 0a2dff4e-cd84-42ff-8141-e89889b24081
---
# Introduction to the C# language and .NET Framework
# Introduction to the C# language and .NET

C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run in the .NET ecosystem. The .NET ecosystem is composed of all the implementations of .NET, including both but not limited to [.NET Core](../../core/introduction.md), and [.NET Framework](../../framework/index.yml). This article focuses on .NET Framework. You can use C# to create Windows client applications, XML Web services, distributed components, client-server applications, database applications, and much, much more.

Expand Down Expand Up @@ -38,19 +38,19 @@ The following are additional C# resources:
- For detailed information about specific aspects of the C# language, see the [C# Reference](../language-reference/index.md).
- For more information about LINQ, see [LINQ (Language-Integrated Query)](../programming-guide/concepts/linq/index.md).

## .NET Framework Platform Architecture
## .NET Platform Architecture

C# programs run on the .NET Framework, an integral component of Windows that includes a virtual execution system called the common language runtime (CLR) and a unified set of class libraries. The CLR is the commercial implementation by Microsoft of the common language infrastructure (CLI), an international standard that is the basis for creating execution and development environments in which languages and libraries work together seamlessly.
C# programs run on .NET, an integral component of Windows that includes a virtual execution system called the common language runtime (CLR) and a unified set of class libraries. The CLR is the commercial implementation by Microsoft of the common language infrastructure (CLI), an international standard that 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)](../../standard/managed-code.md) that conforms to the CLI specification. The IL code and resources, such as bitmaps and strings, are stored on disk in an executable file called an assembly, typically with an extension of .exe or .dll. An assembly contains a manifest that provides information about the assembly's types, version, culture, and security requirements.

When the C# program is executed, the assembly is loaded into the CLR, which might take various actions based on the information in the manifest. Then, if the security requirements are met, the CLR performs Just-In-Time (JIT) compilation to convert the IL code to native machine instructions. The CLR also 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", in contrast to "unmanaged code", which is compiled into native machine language that targets a specific system. The following diagram illustrates the compile-time and run-time relationships of C# source code files, the .NET Framework class libraries, assemblies, and the CLR.
When the C# program is executed, the assembly is loaded into the CLR, which might take various actions based on the information in the manifest. Then, if the security requirements are met, the CLR performs Just-In-Time (JIT) compilation to convert the IL code to native machine instructions. The CLR also 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", in contrast to "unmanaged code", which is compiled into native machine language that targets a specific system. The following diagram illustrates the compile-time and run-time relationships of C# source code files, the .NET class library, assemblies, and the CLR.

![From C# source code to machine execution](./media/introduction-to-the-csharp-language-and-the-net-framework/net-architecture-relationships.png)

Language interoperability is a key feature of the .NET Framework. Because the 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 versions of Visual Basic, Visual C++, or any of more than 20 other CTS-compliant languages. A single assembly may contain multiple modules written in different .NET languages, and the types can reference each other as if they were written in the same language.
Language interoperability is a key feature of .NET. Because the 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 versions of Visual Basic, Visual C++, or any of more than 20 other CTS-compliant languages. A single assembly may contain multiple modules written in different .NET languages, and the types can reference each other as if they were written in the same language.

In addition to the run time services, the .NET Framework also includes an extensive library of over 4000 classes organized into namespaces that provide a wide variety of useful functionality for everything from file input and output to string manipulation to XML parsing, to Windows Forms controls. The typical C# application uses the .NET Framework class library extensively to handle common "plumbing" chores.
In addition to the run time services, .NET also includes an extensive library of over 4000 classes organized into namespaces that provide a wide variety of useful functionality for everything from file input and output to string manipulation to XML parsing, to Windows Forms controls. The typical C# application uses the .NET class library extensively to handle common "plumbing" chores.

For more information about the .NET Framework, see [Overview of the Microsoft .NET Framework](../../framework/get-started/overview.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/how-to/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Events provide a mechanism to publish or subscribe to notifications.

- [Subscribe and unsubscribe from events](../programming-guide/events/how-to-subscribe-to-and-unsubscribe-from-events.md).
- [Implement events declared in interfaces](../programming-guide/events/how-to-implement-interface-events.md).
- [Conform to .NET Framework guidelines when your code publishes events](../programming-guide/events/how-to-publish-events-that-conform-to-net-framework-guidelines.md).
- [Conform to .NET guidelines when your code publishes events](../programming-guide/events/how-to-publish-events-that-conform-to-net-framework-guidelines.md).
- [Raise events defined in base classes from derived classes](../programming-guide/events/how-to-raise-base-class-events-in-derived-classes.md).
- [Implement custom event accessors](../programming-guide/events/how-to-implement-custom-event-accessors.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/how-to/modify-string-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ You could modify a string in a fixed block with unsafe code, but it is **strongl

## See also

- [.NET Framework regular expressions](../../standard/base-types/regular-expressions.md)
- [.NET regular expressions](../../standard/base-types/regular-expressions.md)
- [Regular expression language - quick reference](../../standard/base-types/regular-expression-language-quick-reference.md)
2 changes: 1 addition & 1 deletion docs/csharp/how-to/search-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ This single search pattern matches many valid strings. Regular expressions are b
- [Strings](../programming-guide/strings/index.md)
- [LINQ and strings](../programming-guide/concepts/linq/linq-and-strings.md)
- <xref:System.Text.RegularExpressions.Regex?displayProperty=nameWithType>
- [.NET Framework regular expressions](../../standard/base-types/regular-expressions.md)
- [.NET regular expressions](../../standard/base-types/regular-expressions.md)
- [Regular expression language - quick reference](../../standard/base-types/regular-expression-language-quick-reference.md)
- [Best practices for using strings in .NET](../../standard/base-types/best-practices-strings.md)
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/compiler-messages/cs0029.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ i = (int) lng; // Cast to int.

The third line of code tells the compiler to explicitly convert the variable `lng`, which is of type long, to an int before making the assignment. Remember that with a narrowing conversion, there is a potential loss of data. Narrowing conversions should be used with caution and even though the code will compile you may get unexpected results at run-time.

This discussion has only been for value types. When working with value types you work directly with the data stored in the variable. However, the .NET Framework also has reference types. When working with reference types you are working with a reference to a variable, not the actual data. Examples of reference types would be classes, interfaces and arrays. You cannot implicitly or explicitly convert one reference type to another unless the compiler allows the specific conversion or the appropriate conversion operators are implemented.
This discussion has only been for value types. When working with value types you work directly with the data stored in the variable. However, .NET also has reference types. When working with reference types you are working with a reference to a variable, not the actual data. Examples of reference types would be classes, interfaces and arrays. You cannot implicitly or explicitly convert one reference type to another unless the compiler allows the specific conversion or the appropriate conversion operators are implemented.

The following sample generates CS0029:

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/compiler-messages/cs0234.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The type or namespace name 'name' does not exist in the namespace 'namespace' (a

- You passed a variable name to the [typeof](../operators/type-testing-and-cast.md#typeof-operator) operator.

- You tried to reference an assembly that is not part of your target .NET Framework profile. For more information, see [Troubleshooting .NET Framework Targeting Errors](/visualstudio/msbuild/troubleshooting-dotnet-framework-targeting-errors).
- You tried to reference an assembly that is not part of your .NET target framework moniker (TFM). For more information, see [Troubleshooting .NET Targeting Errors](/visualstudio/msbuild/troubleshooting-dotnet-framework-targeting-errors).

If you see this error after moving code from one development machine to another, make sure that the project on the new machine has the correct references, and that the versions of the assemblies are the same as on the old machine. You can also use the Object Browser to inspect an assembly and verify whether it contains the types that you expect it to contain.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The **-baseaddress** option lets you specify the preferred base address at which
The base address for the DLL. This address can be specified as a decimal, hexadecimal, or octal number.

## Remarks
The default base address for a DLL is set by the .NET Framework common language runtime.
The default base address for a DLL is set by the .NET common language runtime.

Be aware that the lower-order word in this address will be rounded. For example, if you specify 0x11110001, it will be rounded to 0x11110000.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Causes the compiler to make COM type information in the specified assemblies ava

- A field, property, event, or method that has a return type or parameter type from Assembly B is invoked.

Like the [-reference](./reference-compiler-option.md) compiler option, the `-link` compiler option uses the Csc.rsp response file, which references frequently used .NET Framework assemblies. Use the [-noconfig](./noconfig-compiler-option.md) compiler option if you do not want the compiler to use the Csc.rsp file.
Like the [-reference](./reference-compiler-option.md) compiler option, the `-link` compiler option uses the Csc.rsp response file, which references frequently used .NET assemblies. Use the [-noconfig](./noconfig-compiler-option.md) compiler option if you do not want the compiler to use the Csc.rsp file.

The short form of `-link` is `-l`.

Expand Down
Loading