Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update stackalloc reference #4922

Merged
merged 2 commits into from
Apr 12, 2018

Conversation

BillWagner
Copy link
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.
Copy link
Contributor

@rpetrusha rpetrusha left a comment

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
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
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