Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of an NSDictionary in C#?

Tags:

c#

What is the equivalent of an NSDictionary in C#?

Is it a collection?

like image 339
Ethan Allen Avatar asked Dec 10 '11 02:12

Ethan Allen


2 Answers

Its System.Collections.Generic.Dictionary<,>
To set an object (like setObject:forKey:) you use:

Dictionary[Key] = Object;

To get an object (like objectForKey:) you use:

var Object = Dictionary[Key];
like image 127
Dani Avatar answered Oct 07 '22 18:10

Dani


You can also use the HashTable Class:

Example :

HashTable dict = new HashTable();

dict.Add("key", object);
like image 37
Sedat Kilinc Avatar answered Oct 07 '22 17:10

Sedat Kilinc