SystemCollectionsGenericQueue - Core Libraries

A comprehensive guide to the SystemCollectionsGenericQueue class.

Introduction

The SystemCollectionsGenericQueue is a versatile queue implementation available in .NET Core and .NET Framework. It provides efficient and reliable queuing functionality, allowing you to manage asynchronous operations and data streams effectively.

Properties

Methods

The queue provides methods for:

Example

Here's a simple example demonstrating the queue's capabilities:

        
        using System;
        using System.Collections.Generic;

        public class SystemCollectionsGenericQueue
        {
          private readonly List _items = new List();

          public bool IsEmpty() { return _items.Count == 0; }

          public T Get(int index) {
            if (index < 0 || index >= _items.Count) {
              throw new IndexOutOfRangeException("Index out of range");
            }
            return _items[index];
          }

          public void Enqueue(T item) {
            _items.Add(item);
          }

          public T Dequeue() {
            if (_items.Count == 0) {
              throw new InvalidOperationException("Queue is empty");
            }
            return _items.RemoveFirst();
          }
        }