I've had a chance now to spend a fair amount of time with Visual Studio 2008 and so far has been solid. Right now I'm spending a lot of time getting familiar with all the new C# 3.0 features. It's always a lot of work staying ahead of the changes. So far my favorite IDE enhancement has to be the WPF editor, it's come a long way since it's preview days. My favorite language feature has to be Linq or Language integrated query. This is a great addition and it has made one of those often tedious tasks easy.
More than once I've had to compare the contents of two lists to determine what exists in one that isn't in the other. I'm currently working on an app that imports a file, this file is always appended to, so I just need to add the new items to my collection, linq makes it a snap, here's the code.
IEnumerable<string> entryQuery =
(from s1 in entries
select s1).Except
(from s2 in currentEntries
select s2);
//update the current entries to reflect the additions
foreach (string s entryQuery)
{
currentEntries.Add(s);
}
I've seen and implemented Equals on the collection, but most of the time you end up with the same record multiple times, with linq on one copy of any item is added.
No comments:
Post a Comment