I am looking to implement a Queue of type Dictionary<int, string> and be able to iterate/enqueue/dequeue.
What's ultimately needed is a queue of int, string, whatever guise it takes.
So far I have something like:
private static Queue<Dictionary<int, string>> requestQueue = new Queue<Dictionary<int, string>>();
foreach (KeyValuePair<int, string> dictionaryListItem in dictionaryList)
{
requestQueue.Enqueue( dictionaryListItem ); // error
}
but can't seem to enqueue with the above. Would anyone know the correct syntax?
Well, you have a queue of dictionaries, but try to add a single dictionary value to your queue.
If you indeed want to have a queue of dictionaries, you should change your code like this:
requestQueue.Enqueue(dictionaryList);
If you actually want a queue of key value pairs, change your queue to this:
Queue<KeyValuePair<int, string>> requestQueue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With