Cloning queue in c# -


i have following code:

queue<string> oldqueue = new queue<string>();  oldqueue.enqueue("one"); oldqueue.enqueue("two"); oldqueue.enqueue("three");  queue newqueue = oldqueue; string newstring = newqueue.dequeue(); 

the problem once dequeue item newqueue, item dequeued oldqueue. there way "clone" queue in way removing item 1 queue keep it's clone queue unchanged?

queue reference type, newqueue , oldqueue holds pointer same object. same ;-)

see answer how "deep cloning" using reflection:

deep copy using reflection in extension method silverlight?


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

java - How to create Table using Apache PDFBox -

mpi - Why is MPI_Bsend not returning error even when the buffer is insufficient to accommodate all the messages -