ConcurrentStack represents a thread-safe last in-first out (LIFO) collection. : ConcurrentStack « Collections Data Structure « C# / C Sharp






ConcurrentStack represents a thread-safe last in-first out (LIFO) collection.

 

using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
class MainClass
{
        static void Main ()
        {
            ConcurrentStack<int> cs = new ConcurrentStack<int>();
            cs.Push(1);
            cs.Push(2);

            int result;

            cs.TryPeek(out result);
            cs.TryPop(out result);
            cs.Clear();
        }
}

   
  








Related examples in the same category