-4

I have two lists of tests which some of them contain properties (key,value). Lets call them list-A & list-B.

I want to do the following (on list-B only):

1) add test that list-A has and list-B doesn't (with all properties).

2) add property that list-A has and list-B doesn't

3) remove property that list-B has and list-A doesn't

how can I do that in C# with less than 4/5 for loops?

IT ppl
  • 2,626
  • 1
  • 39
  • 56
Fyber
  • 71
  • 1
  • 1
  • 5

1 Answers1

0

If I understant your problem, only two loops are necessary... But what is a property and what is a test in your case? The key is the test and the value is a property?

foreach(type key in a.keys)
{
  //a1 I think. adds a key not in b
  if(!b.ContainsKey(key))
  {
    b.Add(key, a[key]);
  }
  else
  {
    //a2 I think... I suppose that the value is a list of properties
    foreach(type prop in a[key])
    {
      if(!b[key].Contains(prop))
      {
        b[key].Add(prop);
      }
    }
  }
}  
Amaranth
  • 2,433
  • 6
  • 36
  • 58