Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C语言中的数组队列_C# - Fatal编程技术网

C# C语言中的数组队列

C# C语言中的数组队列,c#,C#,需要创建两个阵列队列,每个队列中有4个整数 比如: Queue1[1] {int i1, int i2, int i3, int4} Queue1[2] {int i1, int i2, int i3, int4} etc.. 队列2也一样 ~~编辑~~ 我想跟踪随机生成的int。 最终使用对象的链表。 所以我创建了一个包含我想要的所有整数的对象,然后调用了一个链表 LinkedList<RandomInts> Q = new LinkedList<RandomInts>

需要创建两个阵列队列,每个队列中有4个整数

比如:

Queue1[1] {int i1, int i2, int i3, int4}
Queue1[2] {int i1, int i2, int i3, int4} etc..
队列2也一样

~~编辑~~

我想跟踪随机生成的int。 最终使用对象的链表。 所以我创建了一个包含我想要的所有整数的对象,然后调用了一个链表

LinkedList<RandomInts> Q = new LinkedList<RandomInts>();

这把戏做得很好。谢谢

这其实很简单。实际上,INT队列与任何其他类型的队列没有什么不同。您可以很容易地拥有一个列表队列或一个队列队列或类似的东西

顺便说一下,我正在使用接受IEnumerable的队列构造函数来初始化它们。在第一种情况下,我将从int数组构建一个队列

在第二种情况下,我将从int数组构建一个队列。我将其作为一个例子,因为从您的帖子中不清楚您实际上需要一个数组队列。如果每个队列只包含4个整数,为什么不创建包含4个整数的队列呢?为什么要为整个数组队列而烦恼呢

无论哪种方式,这里的代码:

        // Here you have it - a queue of arrays
        // Really, it's no different than a queue of any other type
        Queue<int[]> queue = new Queue<int[]>(
            // Construct the queue from the following array of arrays
            new[]
            {
                new[] { 3, 2, 1, 0 },
                new[] { 32, 24, 234, 3 }
                // Whatever you want
            }
        );

        // If all you want is a queue with four ints, why bother with the queue of array thing?
        // You can initialize a queue with some numbers like this
        Queue<int> queueOfInts = new Queue<int>(new[] { 3, 2, 1, 0 });

您是否熟悉有关创建和预先定义阵列大小的新术语。。?这就是谷歌的目的。。请在队列上进行谷歌搜索…etcDid您有一个问题吗?为什么要使用队列,如果您知道每次将有4个整数,为什么不使用数组呢?队列的第一项必须在到达目的地后删除,这就是原因。数组包含目的地、性别和其他2个整数。我找不到如何在C语言中实现它,这就是我要问的。我如何创建队列并在之后访问它们,以便填充它们或在ifs/Switch中使用它们。为什么您认为需要一个数组队列?为什么不只是一个整数队列呢?我最终使用了由对象组成的链表。LinkedList q=新的LinkedList;使用q.ElementAtindexOfObj.Whatever;成功了。非常感谢。
        // Here you have it - a queue of arrays
        // Really, it's no different than a queue of any other type
        Queue<int[]> queue = new Queue<int[]>(
            // Construct the queue from the following array of arrays
            new[]
            {
                new[] { 3, 2, 1, 0 },
                new[] { 32, 24, 234, 3 }
                // Whatever you want
            }
        );

        // If all you want is a queue with four ints, why bother with the queue of array thing?
        // You can initialize a queue with some numbers like this
        Queue<int> queueOfInts = new Queue<int>(new[] { 3, 2, 1, 0 });