Skip to content

Instantly share code, notes, and snippets.

@aensidhe
Created June 20, 2019 06:10
Show Gist options
  • Save aensidhe/57d40e4bf5b198316ebb4f5428345412 to your computer and use it in GitHub Desktop.
Save aensidhe/57d40e4bf5b198316ebb4f5428345412 to your computer and use it in GitHub Desktop.
stackalloc valuetuples
using System;
namespace Unsafe
{
class Program
{
static unsafe void Main(string[] args)
{
var v = stackalloc (int, int)[]
{
(1, 1),
(2, 2),
(3, 3),
(4, 4)
};
for (var i = 0; i < 4; i++)
{
Console.WriteLine(v[i]);
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>preview</LangVersion>
</PropertyGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment