-5

I have searched for a few examples and not found one that is similar to what I have and what I want to achieve.

I have 2 lists

class object1
{
   string obj1_name;
   int obj1_qty;
}
List<object1> listA

class object2
{
   string obj2_name;
   int obj2_qty;
}
List<object2> listB;

Now, using ListA as the primary list I want to see if ListB contains an object with the same name and if so, what is the quantity and hence, does the obj1_qty = obj2_qty each other? if not, there is a difference and I need to show it, most likely in a 3rd list which would be the difference, of the qty's if they exist. Note, ListA can be bigger or smaller than ListB

  • Show All List A (master list contains all objects)
  • Show the difference between those names/qty's that exist in both lists.

Gracias


It seems there are multiple ways to accomplish this 'do-later' task . My goal was to use Objective-C and Cocoa as a solution. Initially, I had worries about 'blocking' the main thread in some way. It turns out NSTimer is one answer to the question. I ended up using:

NSTimer *timer = [[NSTimer alloc] initWithFireDate:date
                                          interval:0.1
                                            target:self
                                          selector:@selector(startSomeMethod:)
                                          userInfo:info
                                           repeats:NO];

to 'fire' a task at a later time.

4

2 に答える 2

3

結合がうまくいくように聞こえます:

var query = from a in listA
            join b in listB on a.obj1_name equals b.obj2_name
            where a.obj1_qty != b.obj2_qty
            select new {
                Name = a.obj1_name,
                QtyA = a.obj1_qty,
                QtyB = b.obj2_qty,
                Diff = a.obj1_qty - b.obj2_qty
                };
于 2013-08-27T14:49:41.323 に答える