using namespace System; using namespace System::IO; using namespace System::Collections; using namespace System::Runtime::Serialization::Formatters::Binary;
int main() { /*1*/ Hashtable^ dictionary = gcnew Hashtable(21000);
using namespace System; using namespace System::IO; using namespace System::Collections; using namespace System::Runtime::Serialization::Formatters::Binary;
int main() { BinaryFormatter^ formatter = gcnew BinaryFormatter;
String^ Word; while (true) { Console::Write("Enter a word: "); word = Console::ReadLine(); if (word == nullptr) { break; } /*3*/ Console::WriteLine("{0}{1} found", word, (dictionary->Contains(word) ? "" : " not")); } } 插2:使用反串行化进行字典查找
Dictionary contains 20159 entries Enter a word: house house found Enter a word: houses houses not found Enter a word: brick brick found Enter a word: manly manly not found 此处最重要的是,我们能在单个函数调用中,串行、反串行化任意大小、任意复杂性的对象。 处理多个句柄