Skip to content

Instantly share code, notes, and snippets.

@davidehnis
davidehnis / flatten_array.cs
Last active March 27, 2019 14:44
How to flatten an array of arbitrarily nested arrays
private void Flatten(object item, List<int> flattened)
{
if (item is int i)
{
flattened.Add(i);
return;
}
if (!(item is List<object> list)) return;