I was writing a For…Each loop yesterday to create a comma-delimited string from the properties of objects in a collection (and, thanks to LINQ, I don't write many For…Each loops any more). As I was typing in my code I noticed that the String class's Join method now accepts a collection as one of its parameters. That let me delete my whole For…Each loop because, with this new version of Join, all I have to do is pass the Join method the separator I want between my strings (in this case, a comma) and a collection of strings.
Since the collection I wanted to process was a collection of Customer objects, I did need to include a lambda expression to specify which property on the Customer object I wanted to concatenate (I could also have overridden my Customer's ToString method to return the value I wanted to concatenate). So, in the end, all I needed was this:
Dim res = String.Join(",", db.Customers.Select(Function(c) c.FirstName))
I got back the string "Peter,Jan,Jason…" and so on.
One sad thing: This feature is only available in .NET 4.5. I'm not saying that, all by itself, this feature is a compelling reason to upgrade, but I am now lobbying a little bit harder to get my clients using older versions of .NET to upgrade.
Posted by Peter Vogel on 06/17/2014 at 8:19 AM
User experience expert Debbie Levitt provided some saucy answers about an upcoming Visual Studio Live! presentation with an even saucier title: Fast Focus: WTF UX - UX Research and Design AMA.
Developers can now sign up for a private preview of enhanced chat capabilities coming to GitHub Copilot, the "AI pair programmer" that works in the Visual Studio 2022 IDE and in Visual Studio Code.
With advanced generative AI systems reshaping software development, Microsoft's Mads Kristensen detailed the many ways AI will improve coding in Visual Studio.
With Google recently releasing a generative AI-powered search bot called Bard to rival Microsoft's "new Bing" search experience, we put both to the test, feeding them identical questions about Visual Studio and .NET.
GPT-4, the advanced generative AI model from Microsoft partner OpenAI, is now powering the new GitHub Copilot X and the Azure OpenAI Service.
> More Webcasts