Skip to content

update stackalloc reference - #4922

Merged
BillWagner merged 2 commits into
dotnet:masterfrom
BillWagner:csharp73-stackalloc-iniitalizers
Apr 12, 2018
Merged

update stackalloc reference#4922
BillWagner merged 2 commits into
dotnet:masterfrom
BillWagner:csharp73-stackalloc-iniitalizers

Conversation

@BillWagner

Copy link
Copy Markdown
Member

Starting with C# 7.3, stackalloc arrays can use array initializer syntax.

I also ran acrolinx and fixed markdown lint issues. This will be easier to review with the rich diff.

Fixes #4772

Relies on samples in dotnet/samples#14

Starting with C# 7.3, stackalloc arrays can use array initializer syntax.

I also ran acrolinx and fixed markdown lint issues. This will be easier to review with the rich diff.

@rpetrusha rpetrusha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, @BillWagner. Once again I left just one minor comment.

int* third = stackalloc[] { 1, 2, 3 };
```

Because pointer types are involved, `stackalloc` requires [unsafe](unsafe.md) context. For more information, see [Unsafe Code and Pointers](../../programming-guide/unsafe-code-pointers/index.md)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

requires unsafe --> requires an unsafe


`stackalloc` is like [_alloca](/cpp/c-runtime-library/reference/alloca) in the C run-time library.

## Example2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As the section contains two examples: Example2 -> Examples

@BillWagner
BillWagner merged commit a5bfeb6 into dotnet:master Apr 12, 2018
@BillWagner
BillWagner deleted the csharp73-stackalloc-iniitalizers branch April 12, 2018 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend array initializers to stackalloc arrays

3 participants