using System.Collections.Generic;
using System.Runtime.CompilerServices;
public static void Main()
List<MyItem[]> MyItems = new List<MyItem[]>()
new MyItem[] { new MyItem("Item1") },
new MyItem[] { new MyItem("Item1"), new MyItem("Item2") },
new MyItem[] { new MyItem("Item3") },
new MyItem[] { new MyItem("Item1"), new MyItem("Item3"), new MyItem("Item2") },
new MyItem[] { new MyItem("Item3"), new MyItem("Item1") },
new MyItem[] { new MyItem("Item2"), new MyItem("Item1") }
Dictionary<Tuple<string, string>, int> results = new Dictionary<Tuple<string, string>, int>();
foreach (MyItem[] arr in MyItems)
for (int i = 0; i < arr.Length; i++)
string s1 = arr[i].ItemName;
for (int j = i + 1; j < arr.Length; j++)
string s2 = arr[j].ItemName;
Tuple<string, string> t = new Tuple<string, string>(s1, s2);
if (string.Compare(s1, s2) > 0)
t = new Tuple<string, string>(s2, s1);
if (results.ContainsKey(t))
foreach (var v in results)
Console.WriteLine(v.Key.ToString() + " = " + v.Value.ToString());
public string ItemName { get; set; }
public MyItem(string ItemName)
this.ItemName = ItemName;