شما قبلش باید یک کلاس از IEqualityComparer بسازین و داخلش مشخص کنین که 2 تا String چجوری قراره مقایسه بشن
public class StringCompare : IEqualityComparer<String[]>
{
public bool Equals(String[] x, String[] y)
{
if (x.Length != y.Length)
{
return false;
}
for (int i = 0; i < x.Length; i++)
{
if (x[i] != y[i])
{
return false;
}
}
return true;
}
public int GetHashCode(String[] obj)
{
int result = 7;
for (int i = 0; i < obj.Length; i++)
{
result = result * 7 + obj[i].Length;
}
return result;
}
}
نحوه استفاده :
Dictionary<string[], int> di = new Dictionary<string[], int>(new StringCompare());
di.Add(new string[]{"player1","football"}, 121);
di.Add(new string[]{"player2","vollyball"}, 222);
MessageBox.Show(di[new string[] { "player2", "vollyball" }].ToString());