Skip to content

Instantly share code, notes, and snippets.

View kolebynov's full-sized avatar
😀
Sas

Vitali kolebynov

😀
Sas
View GitHub Profile
@kolebynov
kolebynov / Program.cs
Created May 7, 2024 13:38
Fixed stack/heap array with any element type
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
var list1 = new FixedList<string, Buffer16<string>>();
var list2 = new FixedList<string, Buffer32<string>>();
UseList(ref list1, "Hello");
UseList(ref list2, "World");
Console.WriteLine(list1.GetRef(0));
Console.WriteLine(list2.GetRef(0));
@kolebynov
kolebynov / Program.cs
Created May 7, 2024 13:15
Simple stack/heap dynamic array
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
var list1 = new FixedList16<int>();
var list2 = new FixedList32<int>();
UseList(ref list1, 1);
UseList(ref list2, 2);
static void UseList<TItem, TList>(ref TList list, TItem item)
where TItem : unmanaged