I have two list ,list1 of size 5 elements and list2 of size 6 elements. I want to iterate for larger list size(eg. 6 in this case) using foreach statement but the problem is I am not using if condition to check which list is larger . So how can I do the necessary task.
if (list1.Count>list2.Count) // here I donot want to use if statement
{ // do it in 1 statement only
Size=list1.Count;
foreach (var item in list1)
{
// do something
}
}
else
{
Size = list2.Count;
foreach (var item in list2)
{
// do something
}
}