CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
var items = new[]
{
new[] {"0", "John"},
new[] {"1", "Mike"},
new[] {"2", "John"},
new[] {"3", "Tim"},
};
var distinct = items.Distinct(new SecondIndexComparer()).ToList();
foreach (var item in distinct)
{
Console.WriteLine("{0} {1}", item[0], item[1]);
}
}
private class SecondIndexComparer : IEqualityComparer<string[]>
{
public bool Equals(string[] x, string[] y)
{
return x[1] == y[1];
}
public int GetHashCode(string[] obj)
{
return obj[1].GetHashCode();
}
}
}