Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queue.Clone method usage C#

Tags:

c#

clone

queue

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

How can I use this function?

like image 651
miguelmpn Avatar asked Feb 08 '23 17:02

miguelmpn


1 Answers

Clone is available for old, non-generic Queue class.

With generic Queue you can do:

var copy = new Queue<T>(oldQueue)
like image 102
monoh_ Avatar answered Feb 14 '23 09:02

monoh_