int index = mylist.FindIndex (p => p.id == 1); if (index<0) { mylist.Add (car3); } else { mylist [index] = car3; } This just uses the existing FindIndex to One possible way to do this is to use ToLookup(): Another way to do basically the same thing would be using join: Also, you should really use better variable names. You can select multiple fields using linq Select as shown above in various examples this will return as an Anonymous Type. What are the advantages of running a power tool on 240 V vs 120 V? What positional accuracy (ie, arc seconds) is necessary to view Saturn, Uranus, beyond? The following example depicts the behavior of the Enumerable.Distinctmethod on a What were the most popular text editors for MS-DOS in the 1980s? Your code is O(n m), where n is the length of a and m is the length of b. it will be discarded but, how will you replace older list values? The list IS updated as expected. I have attached my sample program. He also rips off an arm to use as a sword, Identify blue/translucent jelly-like animal on beach, Ubuntu won't accept my choice of password. Browse other questions tagged, Start here for a quick overview of the site, Detailed answers to any questions you might have, Discuss the workings and policies of this site. Why did US v. Assange skip the court of appeal? What should I follow, if two altimeters show different altitudes? Has the cause of a rocket failure ever been mis-identified, such that another launch failed due to the same problem? How would you do a "not in" query with LINQ? Adding EV Charger (100A) in secondary panel (100A) fed off main (200A). What is this brick with a round back and a stud on the side used for? Even if there is a solution out there, I'm not sure I'd use Linq for something like this. What's the cheapest way to buy out a sibling's share of our parents house if I have no cash and want to pay less than the appraised value? Can I use LINQ to find an item in the list? Thanks for contributing an answer to Stack Overflow! What differentiates living as mere roommates from living in a marriage-like relationship? How can I control PNP and NPN transistors together from one pin? Why did DOS-based Windows require HIMEM.SYS to boot? There are certainly ways to (ab)use LINQ to achieve the same results, but I'd consider them to be dirty hacks. LINQ stands for Language Integrated Query. Thanks for contributing an answer to Stack Overflow!
Dalmatian Breeders Uk, Adam Lowry Wife Mark Scheifele, Jaylon Johnson Brother, Articles H