|
To | Do this |
Create a fixed-size array of C++ built-in types. | Use a native C++ array. |
Create a managed array of C++ built-in types. | Use the __gc keyword when creating the array. For int arr1 __gc[] = new int __gc[10]; |
Create an unmanaged array of .NET types. | Use the __nogc keyword when creating the array. For example: Int32 arr2 __nogc[22]; |
Iterate over the members of a managed array. | Either use the Count property with a loop, like this: int arr1 __gc[] = new int __gc[10]; for (int i=0; i<arr1->Count; i++) // do something or get an enumerator and use the MoveNext method and Current property, like this: IEnumerator* ie = sa->GetEnumerator(); while (ie->MoveNext()) Console::WriteLine(Sie->Current); |
Create a dynamic array. | Use the ArrayList class. |
Maintain a list of key/ value pairs. | Use the SortedList or Hashtable classes. |
Maintain a list of strings. | Use the StringCollection class. |
|