c# - Queue.Clone方法使用C#

标签 c# queue clone

我找到了以下解决方案 Clone function in the documentation on MSDN for the Queue class . 但是在我的代码中,出现以下错误:

private Queue<int> myQueue = new Queue<int>();
var clone = myQueue.Clone();

'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?)

如何使用这个功能?

最佳答案

Clone 可用于旧的非通用 Queue 类。

使用通用队列,您可以:

var copy = new Queue<T>(oldQueue)

关于c# - Queue.Clone方法使用C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35438479/

相关文章:

c# - 为什么不同的传委托(delegate)方式在性能上会有如此大的差异?

python - "EOF error"在程序退出时使用多处理队列和线程

Java - 获取方法上的锁获取

azure - 将Azure Web角色部署到云,但不理解数据连接字符串(用于队列)

c# - 尝试克隆 Entity Framework 对象时违反了多重性约束

c# - 将多种内容类型发布到 web api

c# - 如何在 .NET Core 的主布局 View 中呈现特定 Controller 的 Action ?

git - 如何克隆旧的 GIT 提交

c# - .NET 中快速紧凑的对象序列化

git - 忽略来自 Git 存储库及其克隆的版本控制文件