How to create a HashMap in C #

I know that we can create a HashMap in Java. But I want to create a HashMap in C # for my ASP.NET MVC project.

Is it possible to do this? If so, how?

In Java, we can create a HashMap as follows:

import java.util.HashMap;
//...
HashMap<Name, Value> myDictionary = new HashMap<>();
+4
source share
2 answers

Look Dictionary<key,value>at System.Collections.Generic. This is C # "parallel" (although it has some differences, it is closest) HashMapin Java.

+5
source
var myHashMap = new Dictionary<string,object>();

Change the types stringand objectfor all that you need.

+1
source

Source: https://habr.com/ru/post/1621244/


All Articles