Public class A
{
Public string Id {get; The set; }
Public string Name {get; The set; }
Public string Num {get; The set; }
}
Now I have two List collection
List List1=new List (a);
List List2=new List (a);
I want to put the Num list2 assigned to list1 of Num
Because of the large amount of data I don't want to use the loop to assignment
Is there a way to one-time give a property assignment
Help bosses
CodePudding user response:
Don't have to cycle to assignment because1. The large amount of data
2. I want to perform this operation is very frequently
So I'm thinking of any non circular way of assignment
CodePudding user response:
Don't know if the Copy can meet your demandCodePudding user response:
Junction post, don't you want to reply, programmers to abide by the logic, not complying with a garden all day tell you "attack"Circulation, immortal didn't save, we can only say that the hash lookup than list the find fast
But absolutely can't say that, I will not cycle, because the update, you need to do both Microsoft and IBM need cycle, can only say that they can use index, B tree quickly locate records, rather than their circulation
CodePudding user response:
If you say you are replaced with l2 directly L1, let's say you directly L1=l2If you say L1 + L2 linq Concat method directly, it is good to connect directly to the two
From the way you ask us that you're actually to update, left the join, or update by such key
Even if we use linq to write, he must be within the same cycle, set operations, set operations, and difference and complement, the operation is not cycle?
The only thing we can suggest is to use a dictionary, use hash alternative List1, in order to reduce the consumption, find and list2 cycle is inevitable
CodePudding user response: