Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
91585d9
Minor tweek on local-transactions.md (#9178)
alfredmyers Nov 22, 2018
4d646e0
Update about.md
Nov 22, 2018
1b10dc5
Corrected invalid syntax (#9190)
svick Nov 22, 2018
f017cec
Add example to unwrap DU in function parameter (#8576)
theprash Nov 22, 2018
fb23f8f
Merge pull request #9179 from kennethjohnsen/patch-1
richlander Nov 24, 2018
984855d
A smallllllll edit (#9224)
phuctvt Nov 25, 2018
39f44a6
Invalid "Next" link (#9226)
mcrio Nov 25, 2018
14f02fe
Removed not necessary line (#9205)
pkulikov Nov 25, 2018
20b11b2
Remove unused image (#9231)
richlander Nov 25, 2018
09aca45
Update unary operator table with newline (#9222)
cartermp Nov 26, 2018
d3e1d0c
Correct example in working-with-linq.md (#9189)
mikkelbu Nov 26, 2018
747931c
Update when.md (#9197)
mikkelbu Nov 26, 2018
5a669e9
Update arithmetic-operations-on-pointers.md (#9199)
pkulikov Nov 26, 2018
aea3e6f
Update how-to-increment-and-decrement-pointers.md (#9200)
pkulikov Nov 26, 2018
0158062
Update cs0116.md (#9206)
pkulikov Nov 26, 2018
37ffa4b
Fixed inaccuracies (#9214)
pkulikov Nov 26, 2018
ea0f28d
Value types: define simple types (#9215)
pkulikov Nov 26, 2018
73bdb8b
Revised increment and decrement operator articles (#9203)
pkulikov Nov 26, 2018
d5339f1
Revised a pointer member access operator article (#9216)
pkulikov Nov 26, 2018
a4a0076
Fixed spelling mistakes (#9217)
pkulikov Nov 26, 2018
6aa4048
Language reference: mention ref assignment operator (#9230)
pkulikov Nov 26, 2018
546da2f
Update numbers-in-csharp.yml (#9240)
KexyBiscuit Nov 26, 2018
b880853
Update netcore-hosting.md (#9182)
jkotas Nov 26, 2018
8e865bd
fix formatting (#9191)
Julian-Robinson Nov 26, 2018
03b0fbd
Update supportedruntime-element.md (#9194)
ForNeVeR Nov 26, 2018
c9c8d3c
Minor fix (#9235)
ThePiranha Nov 26, 2018
fef7a23
add missing language selector (#9177)
mairaw Nov 26, 2018
7aea6a0
Update com-callable-wrapper.md (#8993)
sharpist Nov 26, 2018
87a498c
Update sentiment-analysis.md (#9249)
briandunnington Nov 26, 2018
86a9460
Update taxi-fare.md (#9246)
briandunnington Nov 27, 2018
f4ece7b
fix typos as identified in #9227 (#9245)
briandunnington Nov 27, 2018
fff4118
Add whitespace formatting guidelines (#9223)
cartermp Nov 27, 2018
8d7336b
Guidance for formatting literals (#9176)
cartermp Nov 27, 2018
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
2 changes: 1 addition & 1 deletion docs/core/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ms.date: 08/01/2018

- **Cross-platform:** Runs on Windows, macOS and Linux [operating systems](https://github.com/dotnet/core/blob/master/os-lifecycle-policy.md).
- **Consistent across architectures:** Runs your code with the same behavior on multiple architectures, including x64, x86, and ARM.
- **Command-line tools:** Includes easy-to-use command-line tools that be used for local development and in continuous-integration scenarios.
- **Command-line tools:** Includes easy-to-use command-line tools that can be used for local development and in continuous-integration scenarios.
- **Flexible deployment:** Can be included in your app or installed side-by-side user- or machine-wide. Can be used with [Docker containers](docker/index.md).
- **Compatible:** .NET Core is compatible with .NET Framework, Xamarin and Mono, via [.NET Standard](../standard/net-standard.md).
- **Open source:** The .NET Core platform is open source, using MIT and Apache 2 licenses. .NET Core is a [.NET Foundation](https://dotnetfoundation.org/) project.
Expand Down
1 change: 0 additions & 1 deletion docs/core/tutorials/netcore-hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ Common AppDomain properties include:
* `APP_NI_PATHS` This list is very similar to APP_PATHS except that it's meant to be paths that will be probed for native images.
* `NATIVE_DLL_SEARCH_DIRECTORIES` This property is a list of paths the loader should probe when looking for native DLLs called via p/invoke.
* `PLATFORM_RESOURCE_ROOTS` This list includes paths to probe in for resource satellite assemblies (in culture-specific sub-directories).
* `AppDomainCompatSwitch` This string specifies which compatibility quirks should be used for assemblies without an explicit Target Framework Moniker (an assembly-level attribute indicating which Framework an assembly is meant to run against). Typically, this should be set to `"UseLatestBehaviorWhenTFMNotSpecified"` but some hosts may prefer to get older Silverlight or Windows Phone compatibility quirks, instead.

In our [simple sample host](https://github.com/dotnet/samples/tree/master/core/hosting), these properties are set up as follows:

Expand Down
8 changes: 5 additions & 3 deletions docs/csharp/language-reference/compiler-messages/cs0116.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ ms.assetid: 4cb137b5-ec29-4c1a-adde-9f8424cb9496
---
# Compiler Error CS0116

A namespace does not directly contain members such as fields or methods
A namespace cannot directly contain members such as fields or methods

Inside a [namespace](../../../csharp/language-reference/keywords/namespace.md), the compiler only accepts classes, structures, unions, enumerations, interfaces, and delegates. This error is often generated by developers from a C/C++ background who forget that in C#, methods and variables must be declared and defined within a struct or class. For more information, see [General Structure of a C# Program](../../../csharp/programming-guide/inside-a-program/general-structure-of-a-csharp-program.md).
A namespace can contain only other namespaces and type declarations. For more information, see the [namespace keyword](../keywords/namespace.md) article.

This error is often generated by developers from a C/C++ background who forget that in C#, methods and variables must be declared and defined within a struct or class.

## Example

Expand Down Expand Up @@ -40,7 +42,7 @@ namespace x
}
```

## See Also
## See also

- [General Structure of a C# Program](../../../csharp/programming-guide/inside-a-program/general-structure-of-a-csharp-program.md)
- [Classes and Structs](../../../csharp/programming-guide/classes-and-structs/index.md)
Expand Down
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/keywords/from-clause.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ In the following example, `numbers` is the data source and `num` is the range va

The compiler infers the type of the range variable when the data source implements <xref:System.Collections.Generic.IEnumerable%601>. For example, if the source has a type of `IEnumerable<Customer>`, then the range variable is inferred to be `Customer`. The only time that you must specify the type explicitly is when the source is a non-generic `IEnumerable` type such as <xref:System.Collections.ArrayList>. For more information, see [How to: Query an ArrayList with LINQ](../../programming-guide/concepts/linq/how-to-query-an-arraylist-with-linq.md).

In the previous example `num` is inferred to be of type `int`. Because the range variable is strongly typed, you can call methods on it or use it in other operations. For example, instead of writing `select num`, you could write `select num.ToString()` to cause the query expression to return a sequence of strings instead of integers. Or you could write `select n + 10` to cause the expression to return the sequence 14, 11, 13, 12, 10. For more information, see [select clause](select-clause.md).
In the previous example `num` is inferred to be of type `int`. Because the range variable is strongly typed, you can call methods on it or use it in other operations. For example, instead of writing `select num`, you could write `select num.ToString()` to cause the query expression to return a sequence of strings instead of integers. Or you could write `select num + 10` to cause the expression to return the sequence 14, 11, 13, 12, 10. For more information, see [select clause](select-clause.md).

The range variable is like an iteration variable in a [foreach](foreach-in.md) statement except for one very important difference: a range variable never actually stores data from the source. It just a syntactic convenience that enables the query to describe what will occur when the query is executed. For more information, see [Introduction to LINQ Queries (C#)](../../programming-guide/concepts/linq/introduction-to-linq-queries.md).
The range variable is like an iteration variable in a [foreach](foreach-in.md) statement except for one very important difference: a range variable never actually stores data from the source. It's just a syntactic convenience that enables the query to describe what will occur when the query is executed. For more information, see [Introduction to LINQ Queries (C#)](../../programming-guide/concepts/linq/introduction-to-linq-queries.md).

## Compound from clauses

Expand Down
1 change: 1 addition & 0 deletions docs/csharp/language-reference/keywords/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ You can combine modifiers to declare a struct as `readonly ref`. A `readonly ref
- [Write safe efficient code](../../write-safe-efficient-code.md)
- [Ref returns and ref locals](../../programming-guide/classes-and-structs/ref-returns.md)
- [Conditional ref expression](../operators/conditional-operator.md#conditional-ref-expression)
- [ref assignment operator](../operators/assignment-operator.md#ref-assignment-operator)
- [Passing Parameters](../../programming-guide/classes-and-structs/passing-parameters.md)
- [Method Parameters](method-parameters.md)
- [C# Reference](../index.md)
Expand Down
6 changes: 2 additions & 4 deletions docs/csharp/language-reference/keywords/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ The C# typing system contains the following categories:

- [Pointer types](../../programming-guide/unsafe-code-pointers/pointer-types.md)

Variables that are value types store data, and those that are reference types store references to the actual data. Reference types are also referred to as objects. Pointer types can be used only in [unsafe](unsafe.md) mode.
Variables that are value types store data, and those that are reference types store references to the actual data. Instances of reference types are also referred to as objects. Pointer types can be used only in [unsafe](unsafe.md) mode.

It's possible to convert a value type to a reference type, and back again to a value type, by using [boxing and unboxing](../../../csharp/programming-guide/types/boxing-and-unboxing.md). With the exception of a boxed value type, you cannot convert a reference type to a value type.

This section also introduces [void](void.md).

Value types are also nullable, which means they can store an additional non-value state. For more information, see [Nullable Types](../../../csharp/programming-guide/nullable-types/index.md).

## See also

- [C# Reference](../index.md)
- [C# Programming Guide](../../programming-guide/index.md)
- [C# Keywords](index.md)
- [Reference Tables for Types](reference-tables-for-types.md)
- [Casting and Type Conversions](../../programming-guide/types/casting-and-type-conversions.md)
- [Types](../../programming-guide/types/index.md)
- [Types](../../programming-guide/types/index.md)
96 changes: 50 additions & 46 deletions docs/csharp/language-reference/keywords/value-types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Value Types (C# Reference)"
ms.date: 07/20/2015
title: "Value types (C# Reference)"
ms.date: 11/26/2018
f1_keywords:
- "cs.valuetypes"
helpviewer_keywords:
Expand All @@ -9,44 +9,48 @@ helpviewer_keywords:
- "C# language, value types"
ms.assetid: 471eb994-2958-49d5-a6be-19b4313f80a3
---
# Value Types (C# Reference)
The value types consist of two main categories:

- [Structs](../../../csharp/language-reference/keywords/struct.md)

- [Enumerations](../../../csharp/language-reference/keywords/enum.md)

Structs fall into these categories:

- Numeric types

- [Integral types](../../../csharp/language-reference/keywords/integral-types-table.md)

- [Floating-point types](../../../csharp/language-reference/keywords/floating-point-types-table.md)

- [bool](../../../csharp/language-reference/keywords/bool.md)

- User defined structs.

## Main Features of Value Types
Variables that are based on value types directly contain values. Assigning one value type variable to another copies the contained value. This differs from the assignment of reference type variables, which copies a reference to the object but not the object itself.

All value types are derived implicitly from the <xref:System.ValueType?displayProperty=nameWithType>.

Unlike with reference types, you cannot derive a new type from a value type. However, like reference types, structs can implement interfaces.

Unlike reference types, a value type cannot contain the `null` value. However, the [nullable types](../../../csharp/programming-guide/nullable-types/index.md) feature does allow for value types to be assigned to `null`.
# Value types (C# Reference)

There are two kinds of value types:

- [Structs](struct.md)

- [Enumerations](enum.md)

## Main features of value types

A variable of a value type contains a value of the type. For example, a variable of the `int` type might contain the value `42`. This differs from a variable of a reference type, which contains a reference to an instance of the type, also known as an object. When you assign a new value to a variable of a value type, that value is copied. When you assign a new value to a variable of a reference type, the reference is copied, not the object itself.

All value types are derived implicitly from the <xref:System.ValueType?displayProperty=nameWithType>.

Each value type has an implicit default constructor that initializes the default value of that type. For information about default values of value types, see [Default Values Table](../../../csharp/language-reference/keywords/default-values-table.md).
Unlike with reference types, you cannot derive a new type from a value type. However, like reference types, structs can implement interfaces.

## Main Features of Simple Types
All of the simple types -- those integral to the C# language -- are aliases of the .NET Framework System types. For example, [int](../../../csharp/language-reference/keywords/int.md) is an alias of <xref:System.Int32?displayProperty=nameWithType>. For a complete list of aliases, see [Built-In Types Table](../../../csharp/language-reference/keywords/built-in-types-table.md).
Value type variables cannot be `null` by default. However, variables of the corresponding [nullable types](../../../csharp/programming-guide/nullable-types/index.md) can be `null`.

Constant expressions, whose operands are all simple type constants, are evaluated at compilation time.
Each value type has an implicit default constructor that initializes the default value of that type. For information about default values of value types, see [Default values table](default-values-table.md).

Simple types can be initialized by using literals. For example, 'A' is a literal of the type `char` and 2001 is a literal of the type `int`.
## Simple types

The *simple types* are a set of predefined struct types provided by C# and comprise the following types:

- [Integral types](integral-types-table.md): integer numeric types and the [char](char.md) type
- [Floating-point types](floating-point-types-table.md)
- [bool](bool.md)

The simple types are identified through keywords, but these keywords are simply aliases for predefined struct types in the <xref:System> namespace. For example, [int](int.md) is an alias of <xref:System.Int32?displayProperty=nameWithType>. For a complete list of aliases, see [Built-in types table](built-in-types-table.md).

The simple types differ from other struct types in that they permit certain additional operations:

- Simple types can be initialized by using literals. For example, `'A'` is a literal of the type `char` and `2001` is a literal of the type `int`.

- You can declare constants of the simple types with the [const](const.md) keyword. It's not possible to have constants of other struct types.

- Constant expressions, whose operands are all simple type constants, are evaluated at compile time.

For more information, see the [Simple types](~/_csharplang/spec/types.md#simple-types) section of the [C# language specification](../language-specification/index.md).

## Initializing Value Types
## Initializing value types

Local variables in C# must be initialized before they are used. For example, you might declare a local variable without initialization as in the following example:

```csharp
Expand Down Expand Up @@ -77,26 +81,26 @@ int myInt = new int();
int myInt = 0;
```

Using the [new](../../../csharp/language-reference/keywords/new.md) operator calls the default constructor of the specific type and assigns the default value to the variable. In the preceding example, the default constructor assigned the value `0` to `myInt`. For more information about values assigned by calling default constructors, see [Default Values Table](../../../csharp/language-reference/keywords/default-values-table.md).
Using the [new](new.md) operator calls the default constructor of the specific type and assigns the default value to the variable. In the preceding example, the default constructor assigned the value `0` to `myInt`. For more information about values assigned by calling default constructors, see [Default values table](default-values-table.md).

With user-defined types, use [new](../../../csharp/language-reference/keywords/new.md) to invoke the default constructor. For example, the following statement invokes the default constructor of the `Point` struct:
With user-defined types, use [new](new.md) to invoke the default constructor. For example, the following statement invokes the default constructor of the `Point` struct:

```csharp
Point p = new Point(); // Invoke default constructor for the struct.
```

After this call, the struct is considered to be definitely assigned; that is, all its members are initialized to their default values.

For more information about the new operator, see [new](../../../csharp/language-reference/keywords/new.md).
For more information about the `new` operator, see [new](new.md).

For information about formatting the output of numeric types, see [Formatting Numeric Results Table](../../../csharp/language-reference/keywords/formatting-numeric-results-table.md).
For information about formatting the output of numeric types, see [Formatting numeric results table](formatting-numeric-results-table.md).

## See Also
## See also

- [C# Reference](../../../csharp/language-reference/index.md)
- [C# Programming Guide](../../../csharp/programming-guide/index.md)
- [C# Keywords](../../../csharp/language-reference/keywords/index.md)
- [Types](../../../csharp/language-reference/keywords/types.md)
- [Reference Tables for Types](../../../csharp/language-reference/keywords/reference-tables-for-types.md)
- [Reference Types](../../../csharp/language-reference/keywords/reference-types.md)
- [C# Reference](../index.md)
- [C# Programming Guide](../../programming-guide/index.md)
- [C# Keywords](index.md)
- [Types](types.md)
- [Reference tables for types](reference-tables-for-types.md)
- [Reference Types](reference-types.md)
- [Nullable types](../../programming-guide/nullable-types/index.md)
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/keywords/when.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can use the `when` contextual keyword to specify a filter condition in two c
Starting with C# 6, `when` can be used in a `catch` statement to specify a condition that must be true for the handler for a specific exception to execute. Its syntax is:

```csharp
catch ExceptionType [e] when (expr)
catch (ExceptionType [e]) when (expr)
```
where *expr* is an expression that evaluates to a Boolean value. If it returns `true`, the exception handler executes; if `false`, it does not.

Expand Down
13 changes: 12 additions & 1 deletion docs/csharp/language-reference/operators/assignment-operator.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "= Operator (C# Reference)"
ms.date: 10/31/2018
ms.date: 11/26/2018
f1_keywords:
- "=_CSharpKeyword"
helpviewer_keywords:
Expand All @@ -27,6 +27,16 @@ The following example demonstrates the usage of the assignment operator to assig

[!code-csharp-interactive[assignment operator](~/samples/snippets/csharp/language-reference/operators/AssignmentExamples.cs#Assignments)]

## ref assignment operator

Beginning with C# 7.3, you can use the ref assignment operator `= ref` to reassign a [ref local](../keywords/ref.md#ref-locals) or [ref readonly local](../keywords/ref.md#ref-readonly-locals) variable. The following example demonstrates the usage of the ref assignment operator:

[!code-csharp[ref assignment operator](~/samples/snippets/csharp/language-reference/operators/AssignmentExamples.cs#RefAssignment)]

In the case of the ref assignment operator, the type of the left operand and the right operand must be the same.

For more information, see the [feature proposal note](https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.3/ref-local-reassignment.md).

## Operator overloadability

A user-defined type cannot overload the assignment operator. However, a user-defined type can define an implicit conversion to another type. That way, the value of a user-defined type can be assigned to a variable, a property, or an indexer element of another type. For more information, see the [implicit](../keywords/implicit.md) keyword article.
Expand All @@ -40,3 +50,4 @@ For more information, see the [Simple assignment](~/_csharplang/spec/expressions
- [C# Reference](../index.md)
- [C# Programming Guide](../../programming-guide/index.md)
- [C# Operators](index.md)
- [ref keyword](../keywords/ref.md)

This file was deleted.

This file was deleted.

This file was deleted.

Loading