carpe2 Posted February 5, 2007 Posted February 5, 2007 Hi, I am a C# developer that has to make some code in managed C++. I have to work with HashTable, but I can´t find ways to access items. I would like something like this in C++: C# Hashtable myTable = new HashTable(); myTable.Add("Add1", "Test"); myTable.Add("Add2", "Test2"); string test = myTable["Add1"].ToString(); C++ Hashtable *myTable = new HashTable(); myTable->Add("Add1", "Test"); myTable->Add("Add2", "Test2"); ????????????????????????????????? Thanks in advance. Quote Adolfo.
MrPaul Posted February 5, 2007 Posted February 5, 2007 get_Item(...) old syntax I assume you're using .Net 1.x, so you have to use the older syntax. In the case of accessing properties, this means using get_ and set_ methods, like so: Hashtable __gc* myTable = __gc new Hashtable(); myTable->Add(S"Add1", S"Test"); myTable->Add(S"Add2", S"Test2"); String __gc* test = myTable->get_Item(S"Add1")->ToString(); In .Net 2.0 there is a new syntax which is a little less clumsy. Good luck :cool: Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.