ArrayList.cpp
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
- // This is the main project file for VC++ application project
- // generated using an Application Wizard.
- #include "stdafx.h"
- #using <mscorlib.dll>
- using namespace System;
- using namespace System::Collections;
- // This is the entry point for this application
- #ifdef _UNICODE
- int wmain(void)
- #else
- int main(void)
- #endif
- {
- Console::WriteLine(S"ArrayList Demo");
- // Create a default ArrayList
- ArrayList* pal = new ArrayList();
- // Look at the count and capacity
- Console::WriteLine("Capacity={0}", __box(pal->Capacity));
- Console::WriteLine("Count={0}", __box(pal->Count));
- // Adjust the capacity
- pal->set_Capacity(10);
- Console::WriteLine("Capacity={0}", __box(pal->Capacity));
- // Add some elements
- pal->Add(__box(0));
- pal->Add(__box(2));
- pal->Add(__box(3));
- pal->Insert(1, __box(1));
- Console::WriteLine("Count is now {0}", __box(pal->Count));
- for (int i=0; i<pal->Count; i++)
- Console::WriteLine("Item({0}) = {1}", __box(i), pal->get_Item(i));
- return 0;
- }