Created
April 16, 2019 13:50
-
-
Save ip75/216f91503d996352e9a66331e8cc9ec9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
static private Queue<long> lifo = new Queue<long>(); | |
static void walk(object[] root) | |
{ | |
if (root == null) throw new ArgumentNullException(nameof(root)); | |
foreach (var o in root) | |
{ | |
if (o is long i) | |
{ | |
lifo.Enqueue(i); | |
} | |
else | |
{ | |
walk((object[]) o); | |
} | |
} | |
} | |
static void Main(string[] args) | |
{ | |
object[] srcData = {new object[] {1L, 2L, new object[] {3L}}, 4L}; | |
walk(srcData); | |
var array = lifo.ToArray(); | |
foreach (var digit in array) | |
{ | |
Console.WriteLine(digit); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment