Enumerable::ToList() - C++ Missing From MSDN

I would like to make one of these entries for every example I don't find on MSDN.
I'm not sure if the intention is to ignore C++ or if this was just expected to be too hard, too easy or too ugly for developers to grasp.

I have submitted this as Community Content on MSDN, also.


Here is the missing example for Enumerable::ToList();

#include "stdafx.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::Linq;

int GetLength(String^ str)
       return str->Length;

void main(void)
       array<String^>^ fruits = { "apple", "passionfruit", "banana", "mango",
                      "orange", "blueberry", "grape", "strawberry" };

       List<int>^ lengths =
                           gcnew List<String^>(fruits),
                                  gcnew Func<String^, int>(GetLength)

       for each(int length in lengths)

 This code produces the following output:


posted @ Monday, February 22, 2010 4:30 PM

Comments on this entry:

# imdrkbs6

Left by BillyFig at 7/23/2017 9:03 AM

Your comment:

(not displayed)


Live Comment Preview: