Queue.Clone方法的用法C# [英] Queue.Clone method usage C#
本文介绍了Queue.Clone方法的用法C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have found the following solutions Clone function in the documentation on MSDN for the Queue class. But in my code, i get the following error:
private Queue<int> myQueue = new Queue<int>();
var clone = myQueue.Clone();
'System.Collections.Generic.Queue'不包含'Clone'的定义,找不到扩展方法'Clone'接受类型为'System.Collections.Generic.Queue'的第一个参数(您是否丢失了?using指令还是程序集引用?)
'System.Collections.Generic.Queue' does not contain a definition for 'Clone' and no extension method 'Clone' accepting a first argument of type 'System.Collections.Generic.Queue' could be found (are you missing a using directive or an assembly reference?)
如何使用此功能?
推荐答案
克隆
可用于旧的非通用 Queue
类.
Clone
is available for old, non-generic Queue
class.
使用通用队列,您可以执行以下操作:
With generic Queue you can do:
var copy = new Queue<T>(oldQueue)
这篇关于Queue.Clone方法的用法C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文