List<authorinfo> aif = new List<authorinfo>();
for (int i = 0; i < 5; i++)
{
aif.Add(null);
}
aif[0] = new authorinfo("The Count of Monte Cristo", "Alexandre", "Dumas", 1844);
aif[1] = new authorinfo("Rendezvous with Rama", "Arthur", "Clark", 1972);
aif[2] = new authorinfo("The Three Musketeers", "Alexandre", "Dumas", 1844);
aif[3] = new authorinfo("Robinson Crusoe", "Daniel", "Defoe", 1719);
aif[4] = new authorinfo("2001: A Space Odyssey", "Arthur", "Clark", 1968);
//authorinfo ai = new authorinfo("The Count of Monte Cristo", "Alexandre", "Dumas", 1844);
foreach (authorinfo i in …Run Code Online (Sandbox Code Playgroud) foreach (int i in a.set)
{
foreach (int k in b.set)
{
if (i < k)
{
return true;
}
else if (i > k)
{
return false;
}
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
我有两套,一套包括3,4,6 b.set包括3,4,5
问题是外循环只迭代一次.但它包含3个元素,为什么呢?