7
में संग्रह का एक संग्रह एक दूसरे को काटना
मैं सूचियों जो मैं एक दूसरे को काटना चाहता हूँ की एक सूची मिल गया है:LINQ
List<List<int>> input = new List<List<int>>();
input.Add(new List<int>() { 1, 2, 4, 5, 8 });
input.Add(new List<int>() { 3, 4, 5 });
input.Add(new List<int>() { 1, 4, 5, 6 });
आउटपुट होना चाहिए:
{ 4, 5 }
यह कैसे एक संक्षिप्त में पूरा किया जा सकता फैशन?
क्या आपको सूचियों का उपयोग करने की आवश्यकता है? हैशसेट का उपयोग क्यों नहीं करें? –
संभावित डुप्लिकेट [Inumerable.Intersect()] के साथ एकाधिक सूचियों के छेड़छाड़ (http://stackoverflow.com/questions/1674742/intersection-of-multiple-lists-with-ienumerable-intersect) – Rawling