[問題]請問VC++ .Net有關Hashtable的問題
大家好:
想請問一下,小弟想寫一隻程式需要以Hashtable做index該怎麼做呢?
要進行index的東西為char msg[] = "aaaa"; (類似這個東西),但是msdn在Hashtable
上用Add加入資料是用Hashtable->("S1", "S2"),但今日我要放的東西不是這麼簡單,
型態轉換上又一直出問題,不知有沒有高手可以救一下? Please...
以下是我的Source Code
// 76451.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
#include "iostream"
#include "atlstr.h"
#include "string.h"
using namespace std;
using namespace System;
using namespace System::Collections;
int _tmain(int argc, _TCHAR* argv[])
{
Hashtable^ table1 = gcnew Hashtable;
char* u1 = "aaa";
char* u2 = new char[4];
for(int i = 0; i < 3; i++)
u2[i] = 'b';
u2[3] = '\0';
table1->Add(*u1, NULL);
table1->Add(*u2, NULL);
IEnumerator^ myEnum = table1->GetEnumerator();
while ( myEnum->MoveNext() )
{
DictionaryEntry de = *safe_cast<DictionaryEntry ^>(myEnum->Current);
Console::WriteLine( "\t{0}:\t{1}", de.Key, de.Value );
}
delete table1;
return 0;
}
--
◢◣ ︵︵ █▔◣ █▔█ █▔▔ █▔█ █▆▉ █ █▔█ █◣█ █▔●
◢◤█◣◢◣ ︵︵ █ █ █▁◤ █▁▁ █▁█ ▉▉▉ █ █▁█ █◥█ █ █
夢之大地 逼逼ㄟ四 █▁◤ █ █ █▁▁ █ █ ▉▉▉ █▁ █ █ █ █ █▁◤
※ Origin: <bbs.ccns.ncku.edu.tw> ◆ From: 220.229.173.14
Programming 近期熱門文章
PTT數位生活區 即時熱門文章