I have a dictionary as follows:
static Dictionary<String ^, List<String ^>^> ^ language_strin开发者_开发问答g_table;
Where I have 17 string
s. For each of 17 string
s there is an associated list of 1500 string
s. Now what i want to do is: compare strings in all the lists at each and every index.
e.x. 1st list 1st element should be compared with all the list's 1st element. Similarly for all the indexes in all the lists.
Why not use loops?
for each(KeyValuePair<String^ , List<String^>^> pair1 in qwe)
{
for each(KeyValuePair<String^ , List<String^>^> pair2 in qwe)
{
if(! pair1.Key->Equals(pair2.Key))
{
for(int i = 0; i< 1500; ++i)
{
SomeCompareFunction(pair1.Value[i],pair2.Value[i])
}
}
}
}
You can compare 2 Lists with Enumerable::SequenceEqual
:
List<String^>^ list1 = ...;
List<String^>^ list2 = ...;
bool equal = Enumerable::SequenceEqual(list1, list2);
You only have to iterate over the dictionary values and compare it as above.
精彩评论