c# - Remove duplicate values from queue -


i have exrecise on have write method queue , remove each part of who`s in queue more once example: 11223344 wil return queue 1234

how can it?

you can use distinct() function of ienumerable:

queue<int> = new queue<int>(); // queue want remove duplicates. queue<int> result = new queue<int>(a.distinct()); 

a queue collection, ienumerable , hence linq extension methods ienumerable types can called.


here's demo : .net fiddle link


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -