Share via


Status, aggregate initialization of CLI arrays

This is a quickie. I have some other blog posts about interesting material on the horizon, but I'm always wary of posting information without knowing whether I'm going to violate NDA by writing about it. There should be a real flurry of activity when we finally get the Whidbey Beta 1 out our doors, but I don't expect that to happen for months, yet. We're in “heads-down“ mode in the FE team, hard at work delivering features that we think will excite and engage our users.

About aggregate initialization. How do you do it with managed arrays? I held the suspicion that you couldn't do it, that we didn't provide a way to do it in the new syntax. Stan showed me how:

using namespace System;
using namespace stdcli::language;

int main(){
array<int>^ numbers = gcnew array<int>{4, 6, 8, 10};
for ( int i=0; i<numbers->Length; i++ )
Console::WriteLine( numbers[i] );
}

That's it. Pretty straightforward, pretty simple.