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
Post a Comment