August 2015 Entries

C++/CLI Enumerable::GroupJoin example for MSDN

Adding to the “Missing from MSDN” series of posts: I find tremendous benefit in the Enumerable::GroupJoin method for mimicking the function of a left outer join in SQL -- the construct where the system reports back to you all “keys” and “values” even if the values (results) are null or empty. With the regular Enumerable::Join, only the Key-Value pairs or groupings are returned when there is an associated result.I had found a nifty way of inverting the join to retrieve non-matching results and it ......

C++/CLI Shell Exercise Code

A number of years ago, I was helping someone on DaniWeb with some code that was (probably) more than they expected. I never got closure on the code because it seemed the requester didn’t understand to use Visual Studio. ANYWAY: I recently revisited that code and realized how differently I would have done things if I created it today. It’s like that old cartoon from on 4/20/2010 where one character can’t stand to see his old code: Well, I had the same reaction to mine (as I frequently ......

Enumerable::SelectMany Example in C++/CLI for MSDN

Here is another example taken (slightly) directly from the MSDN page concerning Enumerable::SelectMany. This example is in C++/CLI and appears to be missing from the list of examples. // MSDN_bb534336_CPP.cpp : main project file. // #include "stdafx.h" using namespace System; using namespace System::Collections::Generic; using namespace System::Linq; public ref class PetOwner ......

C++/CLI Join Generic Method Syntax for MSDN

Here is a code snippet for MSDN where the example for C++/CLI under “Join Generic Method” is missing.The code is slightly different to make more sense (to me) and still can be used in the same spirit.I changed the List objects to array and added a key field to the classes rather than using the data as the key. #include "stdafx.h"using namespace System;using namespace System::Collections::Generi... namespace System::Linq; // ref: System.Core public ref class Owner{public: property String^ Name; ......

Playing with Static Population in C++/CLI

One of the tougher things I’ve tried in C++/CLI (or C++ in general) is to “statically fill” or “populate as close to compile-time as possible” a class or other object. If the object is a simple array-type, the syntax is fairly straightforward. If it is a dot-net type (like an ILookup), it is more difficult. In C#, I frequently convert collections to ILookup and Dictionary without much trouble. In CLI, the syntax is more daunting. Now that Enumerable and I are on speaking terms, I find it easier to ......