我找到了以下解决方案 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/