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 此處最重要的是,我們能在單個函數調用中,串行、反串行化任意大小、任意復雜性的對象。 處理多個句柄