SortedList.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
- {
- SortedList* psl = new SortedList();
- psl->Add(new String("Dilbert"), __box(1044));
- psl->Add(new String("Wally"), __box(2213));
- psl->Add(new String("Ted"), __box(1110));
- psl->Add(new String("Alice"), __box(3375));
- for (int i=0; i<psl->get_Count(); i++)
- Console::WriteLine(psl->GetByIndex(i));
- Console::WriteLine("Value for key 'Alice' is {0}",
- psl->get_Item(new String("Alice")));
- // Change the value associated with key 'Alice'
- psl->set_Item(new String("Alice"), __box(5555));
- // Change the value at index 3
- psl->SetByIndex(3, __box(1010));
- for (int i=0; i<psl->get_Count(); i++)
- Console::WriteLine(psl->GetByIndex(i));
- return 0;
- }