Skip to content

Commit 864e834

Browse files
authored
Merge pull request #4938 from dotnet/master
Update Live with current Master
2 parents acd77ef + 7ddbe74 commit 864e834

33 files changed

+141
-157
lines changed

docs/csharp/language-reference/keywords/codesnippet/CSharp/stackalloc_1.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

docs/csharp/language-reference/keywords/stackalloc.md

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "stackalloc (C# Reference)"
3-
ms.date: 07/20/2015
3+
ms.date: 04/12/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
@@ -10,45 +10,59 @@ f1_keywords:
1010
- "stackalloc"
1111
helpviewer_keywords:
1212
- "stackalloc keyword [C#]"
13-
ms.assetid: adc04c28-3ed2-4326-807a-7545df92b852
14-
caps.latest.revision: 27
1513
author: "BillWagner"
1614
ms.author: "wiwagn"
1715
---
1816
# stackalloc (C# Reference)
19-
The `stackalloc` keyword is used in an unsafe code context to allocate a block of memory on the stack.
20-
21-
```csharp
22-
int* block = stackalloc int[100];
23-
```
24-
25-
## Remarks
26-
The keyword is valid only in local variable initializers. The following code causes compiler errors.
27-
28-
```csharp
29-
int* block;
30-
// The following assignment statement causes compiler errors. You
31-
// can use stackalloc only when declaring and initializing a local
32-
// variable.
33-
block = stackalloc int[100];
34-
```
35-
36-
Because pointer types are involved, `stackalloc` requires [unsafe](../../../csharp/language-reference/keywords/unsafe.md) context. For more information, see [Unsafe Code and Pointers](../../../csharp/programming-guide/unsafe-code-pointers/index.md).
37-
38-
`stackalloc` is like [_alloca](/cpp/c-runtime-library/reference/alloca) in the C run-time library.
39-
40-
The following example calculates and displays the first 20 numbers in the Fibonacci sequence. Each number is the sum of the previous two numbers. In the code, a block of memory of sufficient size to contain 20 elements of type `int` is allocated on the stack, not the heap. The address of the block is stored in the pointer `fib`. This memory is not subject to garbage collection and therefore does not have to be pinned (by using [fixed](../../../csharp/language-reference/keywords/fixed-statement.md)). The lifetime of the memory block is limited to the lifetime of the method that defines it. You cannot free the memory before the method returns.
41-
42-
## Example
43-
[!code-csharp[csrefKeywordsOperator#15](../../../csharp/language-reference/keywords/codesnippet/CSharp/stackalloc_1.cs)]
44-
45-
## Security
46-
Unsafe code is less secure than safe alternatives. However, the use of `stackalloc` automatically enables buffer overrun detection features in the common language runtime (CLR). If a buffer overrun is detected, the process is terminated as quickly as possible to minimize the chance that malicious code is executed.
47-
48-
## C# Language Specification
49-
[!INCLUDE[CSharplangspec](~/includes/csharplangspec-md.md)]
50-
51-
## See Also
17+
The `stackalloc` keyword is used in an unsafe code context to allocate a block of memory on the stack.
18+
19+
```csharp
20+
int* block = stackalloc int[100];
21+
```
22+
23+
## Remarks
24+
25+
The keyword is valid only in local variable initializers. The following code causes compiler errors.
26+
27+
```csharp
28+
int* block;
29+
// The following assignment statement causes compiler errors. You
30+
// can use stackalloc only when declaring and initializing a local
31+
// variable.
32+
block = stackalloc int[100];
33+
```
34+
35+
Beginning with C# 7.3, you can use array initializer syntax for `stackalloc` arrays. All the following declarations declare an array with three elements whose values are the integers `1`, `2`, and `3`:
36+
37+
```csharp
38+
// Valid starting with C# 7.3
39+
int* first = stackalloc int[3] { 1, 2, 3 };
40+
int* second = stackalloc int[] { 1, 2, 3 };
41+
int* third = stackalloc[] { 1, 2, 3 };
42+
```
43+
44+
Because pointer types are involved, `stackalloc` requires an [unsafe](unsafe.md) context. For more information, see [Unsafe Code and Pointers](../../programming-guide/unsafe-code-pointers/index.md)
45+
46+
`stackalloc` is like [_alloca](/cpp/c-runtime-library/reference/alloca) in the C run-time library.
47+
48+
## Examples
49+
50+
The following example calculates and displays the first 20 numbers in the Fibonacci sequence. Each number is the sum of the previous two numbers. In the code, a block of memory of sufficient size to contain 20 elements of type `int` is allocated on the stack, not the heap. The address of the block is stored in the pointer `fib`. This memory is not subject to garbage collection and therefore does not have to be pinned (by using [fixed](fixed-statement.md)). The lifetime of the memory block is limited to the lifetime of the method that defines it. You cannot free the memory before the method returns.
51+
52+
[!code-csharp[csrefKeywordsOperator#15](../../../../samples/snippets/csharp/keywords/StackAllocExamples.cs#1)]
53+
54+
The following example initializes a `stackalloc` array of integers to a bit mask with one bit set in each element. This demonstrates the new initializer syntax available starting in C# 7.3:
55+
56+
[!code-csharp[csrefKeywordsOperator#15](../../../../samples/snippets/csharp/keywords/StackAllocExamples.cs#2)]
57+
58+
## Security
59+
60+
Unsafe code is less secure than safe alternatives. However, the use of `stackalloc` automatically enables buffer overrun detection features in the common language runtime (CLR). If a buffer overrun is detected, the process is terminated as quickly as possible to minimize the chance that malicious code is executed.
61+
62+
## C# Language Specification
63+
[!INCLUDE[CSharplangspec](~/includes/csharplangspec-md.md)]
64+
65+
## See Also
5266
[C# Reference](../../../csharp/language-reference/index.md)
5367
[C# Programming Guide](../../../csharp/programming-guide/index.md)
5468
[C# Keywords](../../../csharp/language-reference/keywords/index.md)

docs/csharp/language-reference/keywords/yield.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ foreach (string element in elements)
7474
On each subsequent iteration of the `foreach` loop, the execution of the iterator body continues from where it left off, again stopping when it reaches a `yield return` statement. The `foreach` loop completes when the end of the iterator method or a `yield break` statement is reached.
7575

7676
## Example
77-
The following example has a `yield return` statement that's inside a `for` loop. Each iteration of the `foreach` statement body in `Process` creates a call to the `Power` iterator function. Each call to the iterator function proceeds to the next execution of the `yield return` statement, which occurs during the next iteration of the `for` loop.
77+
The following example has a `yield return` statement that's inside a `for` loop. Each iteration of the `foreach` statement body in the `Main` method creates a call to the `Power` iterator function. Each call to the iterator function proceeds to the next execution of the `yield return` statement, which occurs during the next iteration of the `for` loop.
7878

7979
The return type of the iterator method is <xref:System.Collections.IEnumerable>, which is an iterator interface type. When the iterator method is called, it returns an enumerable object that contains the powers of a number.
8080

docs/framework/deployment/guide-for-administrators.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: ".NET Framework Deployment Guide for Administrators"
33
ms.custom: ""
4-
ms.date: "03/30/2017"
4+
ms.date: "04/10/2018"
55
ms.prod: ".net-framework"
66
ms.reviewer: ""
77
ms.suite: ""
@@ -160,7 +160,7 @@ This step-by-step article describes how a system administrator can deploy the [!
160160

161161
8. Complete the wizard.
162162

163-
The packagenow contains all the information you need to silently deploy the .NET Framework 4.5. Before you deploy the package and program, verify that it was installed on the distribution point; see the "Monitor Content" section of [Operations and Maintenance for Content Management in Configuration Manager](http://technet.microsoft.com/library/gg712694.aspx#BKMK_MonitorContent) in the Configuration Manager Documentation Library.
163+
The package now contains all the information you need to silently deploy the .NET Framework 4.5. Before you deploy the package and program, verify that it was installed on the distribution point; see the "Monitor Content" section of [Operations and Maintenance for Content Management in Configuration Manager](http://technet.microsoft.com/library/gg712694.aspx#BKMK_MonitorContent) in the Configuration Manager Documentation Library.
164164

165165
<a name="deploying_package"></a>
166166
### Deploy the package
@@ -225,12 +225,16 @@ This step-by-step article describes how a system administrator can deploy the [!
225225
## Troubleshooting
226226

227227
### Log file locations
228-
The following log files are generated during [!INCLUDE[net_v45](../../../includes/net-v45-md.md)] setup:
228+
The following log files are generated during .NET Framework setup:
229229

230-
%temp%\Microsoft .NET Framework 4.5*.txt
231-
%temp%\Microsoft .NET Framework 4.5*.html
230+
%temp%\Microsoft .NET Framework *version*\*.txt
231+
%temp%\Microsoft .NET Framework *version*\*.html
232232

233-
You can use the [log collection tool](http://www.microsoft.com/download/details.aspx?id=12493) to collect the [!INCLUDE[net_v45](../../../includes/net-v45-md.md)] log files and to create a compressed cabinet (.cab) file that reduces the size of the files.
233+
where *version* is the version of the .NET Framework that you're installing, such as 4.5 or 4.7.2.
234+
235+
You can also specify the directory to which log files are written by using the `/log` command-line option in the .NET Framework installation command. For more information, see [.NET Framework deployment guide for developers](deployment-guide-for-developers.md#command-line-options).
236+
237+
You can use the [log collection tool](https://www.microsoft.com/download/details.aspx?id=12493) to collect the .NET Framework log files and to create a compressed cabinet (.cab) file that reduces the size of the files.
234238

235239
<a name="return_codes"></a>
236240
### Return codes

0 commit comments

Comments
 (0)